Skip to content

Commit

Permalink
Update carousel if items list transition was broken
Browse files Browse the repository at this point in the history
  • Loading branch information
vadymshymko committed Feb 9, 2023
1 parent 874b93c commit 4017871
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ function ReactSimplyCarousel({
const innerRef = useRef<HTMLDivElement>(null);
const itemsListRef = useRef<HTMLDivElement>(null);

const itemsListDragStartPosRef = useRef<number>(0);
const itemsListDragStartPosRef = useRef(0);
const isListDraggingRef = useRef(false);
const isListTransitionBrokenRef = useRef(false);

const directionRef = useRef<NavDirection | ''>('');

Expand Down Expand Up @@ -807,7 +808,7 @@ function ReactSimplyCarousel({
directionRef.current = '';

if (activeSlideIndex !== positionIndex) {
if (!speed && !delay) {
if ((!speed && !delay) || isListTransitionBrokenRef.current) {
setPositionIndex(activeSlideIndex);
}
} else {
Expand Down Expand Up @@ -894,6 +895,8 @@ function ReactSimplyCarousel({

renderedSlidesCountRef.current = 0;
firstRenderSlideIndexRef.current = positionIndex;
isListTransitionBrokenRef.current =
itemsListRef.current?.style.transform === itemsListTransform;

return (
<div
Expand Down

0 comments on commit 4017871

Please sign in to comment.