FormidableLabs / react-swipeable

React swipe event handler hook
https://commerce.nearform.com/open-source/react-swipeable
MIT License
1.99k stars 146 forks source link

update delta to allow different thresholds for each side #260

Closed macabeus closed 3 years ago

macabeus commented 3 years ago

Closes https://github.com/FormidableLabs/react-swipeable/issues/258

Now it's possible to set a different delta for each side:

<SwipeableUsingHook
  delta={{
    right: 10,
    left: 20,
    up: 30,
    down: 40,
  }}
/>

It also exports a new type: ConfigurationOptionDelta. As requested by @hartzis, delta's type is tied with dir's type:

export type ConfigurationOptionDelta =
  | number
  | { [key in Uncapitalize<SwipeDirections>]: number };
hartzis commented 3 years ago

@macabeus Thank you for setting up the PR for this. My tentative goal is try to look at this this week or next.

It does appear to be failing the build so i'm curious what that is related to, possibly our version of typescript and/or microbundle. We may need to Upgrade to microbundle@0.13.0, which uses typescript@4 like #241 does 🤔

macabeus commented 3 years ago

@hartzis Okay. I did a cherry-pick with @stefvhuynh's commit, updating microbundle to 0.13.3. With this bump, I needed to increase the size limit, because it was exceeding by 151 B:

✔ Adding to empty webpack project

  Package size limit has exceeded by 151 B
  Size limit: 1.15 kB
  Size:       1.3 kB  with all dependencies, minified and gzipped