Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
fix(deps): update dependency react-use-gesture to v9 (#170)
Browse files Browse the repository at this point in the history
* fix(deps): update dependency react-use-gesture to v9

* fix(sliding): Correct sliding behaviour with active flag

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Max Strübing <max.struebing@farbenmeer.de>
  • Loading branch information
3 people committed Feb 2, 2021
1 parent 12f7f60 commit c2a6de3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-spring": "^8.0",
"react-use-gesture": "^8.0.1",
"react-use-gesture": "^9.0.0",
"styled-components": "^5.2.1"
},
"devDependencies": {
Expand Down
20 changes: 12 additions & 8 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const Slider: React.FunctionComponent<SliderProps> = ({
distance,
cancel,
first,
active,
}) => {
if (first) {
setDragging(true);
Expand All @@ -123,18 +124,21 @@ const Slider: React.FunctionComponent<SliderProps> = ({

if (down && distance > width / 2) {
if (cancel) cancel();
setSlide(
clamp(
slide + (xDir > 0 ? -1 : 1),
0,
children.length - slidesAtOnce
)
);
if (active) {
setSlide(
clamp(
slide + (xDir > 0 ? -1 : 1),
0,
children.length - slidesAtOnce
)
);
}
}

// see: https://github.com/react-spring/react-spring/issues/861
// @ts-ignore
setSpringProps((index) => ({
offset: (down ? xDelta : 0) / width + (index - slide),
offset: (active && down ? xDelta : 0) / width + (index - slide),
}));
}
},
Expand Down

0 comments on commit c2a6de3

Please sign in to comment.