Skip to content

Commit

Permalink
feat(🍃): Make spring() configurable (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Jul 9, 2019
1 parent cd883b8 commit e718431
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,15 @@ export const spring = (
translation: Animated.Value<number>,
state: Animated.Value<GestureState>,
snapPoint: Animated.Adaptable<number>,
defaultOffset: number = 0
defaultOffset: number = 0,
springConfig?: Animated.SpringConfig
) => {
const springedValue = new Value(0);
const offset = new Value(defaultOffset);
const clock = new Clock();
const rerunSpring = new Value(0);
// http://chenglou.github.io/react-motion/demos/demo5-spring-parameters-chooser/
const springConfig = {
const config = springConfig || {
toValue: new Value(0),
damping: 15,
mass: 1,
Expand All @@ -105,7 +106,7 @@ export const spring = (
[
set(
springedValue,
runSpring(clock, add(translation, offset), snapPoint, springConfig)
runSpring(clock, add(translation, offset), snapPoint, config)
)
],
[
Expand Down

0 comments on commit e718431

Please sign in to comment.