UNPKG

svelte-motion

Version:

Svelte animation library based on the React library framer-motion.

32 lines (28 loc) 903 B
/** based on framer-motion@4.1.11, Copyright (c) 2018 Framer B.V. */ import {fixed} from '../../../utils/fix-process-env'; import { mix } from 'popmotion'; function tweenAxis(target, prev, next, p) { target.min = mix(prev.min, next.min, p); target.max = mix(prev.max, next.max, p); } function calcRelativeOffsetAxis(parent, child) { return { min: child.min - parent.min, max: child.max - parent.min, }; } function calcRelativeOffset(parent, child) { return { x: calcRelativeOffsetAxis(parent.x, child.x), y: calcRelativeOffsetAxis(parent.y, child.y), }; } function checkIfParentHasChanged(prev, next) { var prevId = prev.getLayoutId(); var nextId = next.getLayoutId(); return prevId !== nextId || (nextId === undefined && prev !== next); } export { calcRelativeOffset, calcRelativeOffsetAxis, checkIfParentHasChanged, tweenAxis };