Skip to content

Commit

Permalink
perf: carousel
Browse files Browse the repository at this point in the history
  • Loading branch information
Yang committed May 8, 2023
1 parent de00ef8 commit 1403faf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions packages/zarm/src/carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,13 @@ const Carousel = forwardRef<CarouselHTMLElement, CarouselProps>((props, ref) =>
);

useEffect(() => {
if (!autoPlay || isDragging) return;
const interval = window.setInterval(() => {
if (!autoPlay || count <= 1) return;
let interval;
if (isDragging) {
interval && window.clearInterval(interval);
return;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L264 was not covered by tests
}
interval = window.setInterval(() => {

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L266 was not covered by tests
if (!loop && stateRef.current.activeIndex === count) {
interval && clearInterval(interval);
return false;
Expand Down
2 changes: 1 addition & 1 deletion packages/zarm/src/carousel/style/component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@include e(items) {
display: flex;
transform-style: preserve-3d;
// transform-style: preserve-3d;
transition-property: transform;
}

Expand Down

0 comments on commit 1403faf

Please sign in to comment.