Skip to content

Instantly share code, notes, and snippets.

@jbowa
Created July 14, 2020 06:55
Show Gist options
  • Save jbowa/bb5d7cebfa56a4cdbce07f0a9e1ee879 to your computer and use it in GitHub Desktop.
Save jbowa/bb5d7cebfa56a4cdbce07f0a9e1ee879 to your computer and use it in GitHub Desktop.
return block([
startClock(clock),
set(delta, diff(translationY)),
cond(
eq(gestureState, State.ACTIVE),
[
set(isSpringing, 0),
set(
state.position,
add(
state.position,
cond(
isInBound,
delta,
multiply(delta, friction(min(divide(abs(overScroll), containerHeight), 1)))
)
)
),
set(state.velocity, velocityY),
set(state.time, 0)
],
[
set(translationY, 0),
cond(
and(isInBound, not(isSpringing)),
[decay(clock, state, {deceleration: 0.997})],
[
set(isSpringing, 1),
set(
config.toValue,
snapPoint(state.position, state.velocity, [lowerBound, upperBound])
),
spring(clock, state, config)
]
)
]
),
state.position
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment