MCPcopy
hub / github.com/osdnk/react-native-reanimated-bottom-sheet / withDecaying

Function withDecaying

src/index.tsx:249–293  ·  view source on GitHub ↗
(
  drag: Animated.Node<number>,
  state: Animated.Node<number>,
  decayClock: Animated.Clock,
  velocity: Animated.Node<number>,
  prevent: Animated.Value<number>
)

Source from the content-addressed store, hash-verified

247}
248
249function withDecaying(
250 drag: Animated.Node<number>,
251 state: Animated.Node<number>,
252 decayClock: Animated.Clock,
253 velocity: Animated.Node<number>,
254 prevent: Animated.Value<number>
255) {
256 const valDecayed = new Value(0)
257 const offset = new Value(0)
258 // since there might be moar than one clock
259 const wasStartedFromBegin = new Value(0)
260 return block([
261 cond(
262 eq(state, GestureState.END),
263 [
264 cond(
265 prevent,
266 stopClock(decayClock),
267 set(
268 valDecayed,
269 runDecay(
270 decayClock,
271 add(drag, offset),
272 velocity,
273 wasStartedFromBegin
274 )
275 )
276 ),
277 ],
278 [
279 stopClock(decayClock),
280 cond(eq(state, GestureState.BEGAN), set(prevent, 0)),
281 cond(
282 or(eq(state, GestureState.BEGAN), eq(state, GestureState.ACTIVE)),
283 set(wasStartedFromBegin, 0)
284 ),
285 cond(eq(state, GestureState.BEGAN), [
286 set(offset, sub(valDecayed, drag)),
287 ]),
288 set(valDecayed, add(drag, offset)),
289 ]
290 ),
291 valDecayed,
292 ])
293}
294
295export default class BottomSheetBehavior extends React.Component<Props, State> {
296 static defaultProps = {

Callers 1

constructorMethod · 0.85

Calls 1

runDecayFunction · 0.85

Tested by

no test coverage detected