UNPKG

motion

Version:

The Motion library for the web

28 lines (23 loc) 1.07 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var animateStyle = require('./animate-style.cjs.js'); var options = require('./utils/options.cjs.js'); var resolveElements = require('./utils/resolve-elements.cjs.js'); var controls = require('./utils/controls.cjs.js'); var stagger = require('../../utils/stagger.cjs.js'); function animate(elements, keyframes, options$1 = {}) { elements = resolveElements.resolveElements(elements); const animations = []; const numElements = elements.length; for (let i = 0; i < numElements; i++) { const element = elements[i]; for (const key in keyframes) { const valueOptions = options.getOptions(options$1, key); valueOptions.delay = stagger.resolveOption(valueOptions.delay, i, numElements); const animation = animateStyle.animateStyle(element, key, keyframes[key], valueOptions); animation && animations.push(animation); } } return controls.createAnimationControls(animations); } exports.animate = animate;