Browse Source

check transition type #16

pull/22/head
Mikael Finstad 6 years ago
parent
commit
d793003b72
  1. 9
      index.js

9
index.js

@ -15,6 +15,9 @@ const GlTransitions = require('./glTransitions');
// Cache // Cache
const loadedFonts = []; const loadedFonts = [];
// See #16
const checkTransition = (transition) => assert(transition == null || typeof transition === 'object', `Invalid transition ${transition}`);
module.exports = async (config = {}) => { module.exports = async (config = {}) => {
const { const {
@ -36,6 +39,8 @@ module.exports = async (config = {}) => {
const audioFilePath = isGif ? undefined : audioFilePathIn; const audioFilePath = isGif ? undefined : audioFilePathIn;
checkTransition(defaultsIn.transition);
const defaults = { const defaults = {
duration: 4, duration: 4,
...defaultsIn, ...defaultsIn,
@ -107,7 +112,9 @@ module.exports = async (config = {}) => {
} }
const clips = await pMap(clipsIn, async (clip, clipIndex) => { const clips = await pMap(clipsIn, async (clip, clipIndex) => {
const { transition: userTransition, duration: userDuration, layers } = { ...clip };
const { transition: userTransition, duration: userDuration, layers } = clip;
checkTransition(userTransition);
const videoLayers = layers.filter((layer) => layer.type === 'video'); const videoLayers = layers.filter((layer) => layer.type === 'video');
assert(videoLayers.length <= 1, 'Max 1 video per layer'); assert(videoLayers.length <= 1, 'Max 1 video per layer');

Loading…
Cancel
Save