Skip to content

Commit

Permalink
pref: carousel
Browse files Browse the repository at this point in the history
  • Loading branch information
Yang committed May 11, 2023
1 parent 9752fe1 commit 2ec2ec3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/zarm/src/carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,18 @@ const Carousel = forwardRef<CarouselHTMLElement, CarouselProps>((props, ref) =>
const bind = useDrag(
(state) => {
let { activeIndex } = stateRef.current;
if (onMoving.current) {
if (activeIndex <= 0) {
onJumpTo(0);

Check warning on line 210 in packages/zarm/src/carousel/index.tsx

View check run for this annotation

Codecov / codecov/patch

packages/zarm/src/carousel/index.tsx#L210

Added line #L210 was not covered by tests
} else if (activeIndex >= count - 1) {
onJumpTo(count - 1);

Check warning on line 212 in packages/zarm/src/carousel/index.tsx

View check run for this annotation

Codecov / codecov/patch

packages/zarm/src/carousel/index.tsx#L212

Added line #L212 was not covered by tests
}
onMoving.current = false;

Check warning on line 214 in packages/zarm/src/carousel/index.tsx

View check run for this annotation

Codecov / codecov/patch

packages/zarm/src/carousel/index.tsx#L214

Added line #L214 was not covered by tests
}
if (!state.intentional) {
return false;

Check warning on line 217 in packages/zarm/src/carousel/index.tsx

View check run for this annotation

Codecov / codecov/patch

packages/zarm/src/carousel/index.tsx#L217

Added line #L217 was not covered by tests
};
intervalRef.current && window.clearInterval(intervalRef.current);
if (onMoving.current) {
return false;
}

const { offset, elapsedTime } = state;

Expand Down

0 comments on commit 2ec2ec3

Please sign in to comment.