UNPKG

react-native-redash

Version:

Utility library for React Native Reanimated

2 lines 1.06 kB
import Animated from"react-native-reanimated";import{State as GestureState}from"react-native-gesture-handler";import{runDecay}from"./AnimationRunners";var Clock=Animated.Clock,Value=Animated.Value,add=Animated.add,block=Animated.block,cond=Animated.cond,eq=Animated.eq,set=Animated.set,stopClock=Animated.stopClock,sub=Animated.sub;export var preserveOffset=function preserveOffset(value,state){var prev=new Value(0);var offset=new Value(0);return block([cond(eq(state,GestureState.BEGAN),[set(prev,0)],[set(offset,add(offset,sub(value,prev))),set(prev,value)]),offset]);};export var decay=function decay(value,state,velocity){var decayedValue=new Value(0);var offset=new Value(0);var clock=new Clock();var rerunDecaying=new Value(0);return block([cond(eq(state,GestureState.END),[set(decayedValue,runDecay(clock,add(value,offset),velocity,rerunDecaying))],[stopClock(clock),cond(eq(state,GestureState.BEGAN),[set(rerunDecaying,0),set(offset,sub(decayedValue,value))]),set(decayedValue,add(value,offset))]),decayedValue]);}; //# sourceMappingURL=Gesture.js.map