How to use the react-native-redash.runSpring function in react-native-redash

To help you get started, we’ve selected a few react-native-redash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wcandillon / can-it-be-done-in-react-native / season2 / bbc-iplayer / components / PanGesture.tsx View on Github external
});
  const translateX = preserveOffset(translationX, state);
  const increment = divide(diff(translateX), ratio);
  const setIndex = (value: Animated.Node) =>
    set(index, modulo(value, length));
  useCode(
    block([
      setIndex(sub(index, increment)),
      cond(eq(state, State.BEGAN), [stopClock(clock), set(isActive, 1)]),
      cond(eq(state, State.END), [
        set(state, State.UNDETERMINED),
        set(shouldSnap, 1)
      ]),
      cond(eq(shouldSnap, 1), [
        setIndex(
          runSpring(
            clock,
            index,
            snapPoint(index, divide(velocityX, -ratio), [
              ceil(index),
              floor(index)
            ]),
            springConfig
          )
        ),
        cond(not(clockRunning(clock)), [set(shouldSnap, 0), set(isActive, 0)])
      ])
    ]),
    []
  );
  return (
github wcandillon / can-it-be-done-in-react-native / season2 / bbc-iplayer / components / ChannelIcon.tsx View on Github external
export default ({
  name,
  radius,
  isActive,
  index,
  currentIndex
}: ChannelIconProps) => {
  const clock = new Clock();
  const value = new Value(0);
  useCode(
    block([
      cond(and(not(isActive), approximates(index, currentIndex)), [
        set(value, runSpring(clock, 0, 1)),
        cond(not(clockRunning(clock)), set(isActive, 0))
      ]),
      cond(isActive, [stopClock(clock), set(value, 0)])
    ]),
    []
  );
  const backgroundColor = interpolateColor(
    value,
    {
      inputRange: [0, 1],
      outputRange: [nonActiveColor, activeColor]
    },
    "rgb"
  );
  return (
github wcandillon / can-it-be-done-in-react-native / bonuses / tinder-swipe / components / Interactable.tsx View on Github external
() => block([
              cond(eq(state, State.END), [
                set(snapPointX, snapPoint(translationX, velocityX, points)),
                set(spring, runSpring(clock, 0, 1)),
                cond(
                  eq(clockRunning(clock), 0),
                  call([snapPointX], ([x]) => onSnap({ nativeEvent: { x } })),
                ),
              ]),
              set(
                x,
                cond(
                  eq(state, State.ACTIVE),
                  translationX,
                  binaryInterpolation(spring, translationX, snapPointX),
                ),
              ),
              set(
                y,
                cond(