UNPKG

@smoovy/tween

Version:
36 lines (35 loc) 1 kB
"use strict"; import { Timeline } from "../timeline"; import { fromTo, to } from "./tween"; function timeline(config = {}) { return new Timeline(config); } function staggerTo(targets, props, config) { return new Timeline({ ...config?.timeline, items: Array.from(targets).map((target) => { const stagger = { offset: typeof config?.stagger?.offset !== "undefined" ? -1 + config.stagger.offset : -1 }; return { controller: to(target, props, config), config: stagger }; }) }); } function staggerFromTo(targets, fromProps, toProps, config) { return new Timeline({ ...config?.timeline, items: Array.from(targets).map((target) => { const stagger = { offset: typeof config?.stagger?.offset !== "undefined" ? -1 + config.stagger.offset : -1 }; return { controller: fromTo(target, fromProps, toProps, config), config: stagger }; }) }); } export { timeline, staggerTo, staggerFromTo };