UNPKG

react-native-redash

Version:

Utility library for React Native Reanimated

2 lines 1.02 kB
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import Animated from"react-native-reanimated";import{min}from"./Math";var Value=Animated.Value,add=Animated.add,multiply=Animated.multiply,cond=Animated.cond,eq=Animated.eq,abs=Animated.abs,sub=Animated.sub,interpolate=Animated.interpolate,divide=Animated.divide;export var snapPoint=function snapPoint(value,velocity,points){var point=add(value,multiply(0.2,velocity));var diffPoint=function diffPoint(p){return abs(sub(point,p));};var deltas=points.map(function(p){return diffPoint(p);});var minDelta=min.apply(void 0,_toConsumableArray(deltas));return points.reduce(function(acc,p){return cond(eq(diffPoint(p),minDelta),p,acc);},new Value());};export var bInterpolate=function bInterpolate(value,origin,destination){return interpolate(value,{inputRange:[0,1],outputRange:[origin,destination]});};export var translateZ=function translateZ(perspective,z){return{scale:divide(perspective,sub(perspective,z))};}; //# sourceMappingURL=Animations.js.map