@vkontakte/vkui 7.6.3 → 7.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "module",
3
- "version": "7.6.3",
3
+ "version": "7.6.4",
4
4
  "name": "@vkontakte/vkui",
5
5
  "description": "VKUI library",
6
6
  "module": "./dist/index.js",
@@ -83,7 +83,8 @@ export const CarouselBase = ({
83
83
  const shiftXCurrentRef = React.useRef<number>(0);
84
84
  const shiftXDeltaRef = React.useRef<number>(0);
85
85
  const initialized = React.useRef<boolean>(false);
86
- const { addToAnimationQueue, getAnimateFunction, startAnimation } = useSlideAnimation();
86
+ const { animationInQueue, addToAnimationQueue, getAnimateFunction, startAnimation } =
87
+ useSlideAnimation();
87
88
  const isDragging = React.useRef(false);
88
89
 
89
90
  const [controlElementsState, setControlElementsState] =
@@ -195,6 +196,7 @@ export const CarouselBase = ({
195
196
  shiftXCurrentRef.current = Math.abs(shiftXDeltaRef.current) + snaps[0];
196
197
  }
197
198
  transformCssStyles(shiftX, animation);
199
+ animationFrameRef.current = null;
198
200
  });
199
201
  };
200
202
 
@@ -308,6 +310,12 @@ export const CarouselBase = ({
308
310
  );
309
311
  }
310
312
 
313
+ const isAnimationInProgress = animationInQueue() || animationFrameRef.current !== null;
314
+
315
+ if (isAnimationInProgress) {
316
+ return;
317
+ }
318
+
311
319
  shiftXCurrentRef.current = snaps[slideIndex];
312
320
  initialized.current = true;
313
321
 
@@ -9,6 +9,7 @@ export function useSlideAnimation(): {
9
9
  getAnimateFunction: (drawFunction: DrawInterface) => () => void;
10
10
  addToAnimationQueue: (func: VoidFunction) => void;
11
11
  startAnimation: () => void;
12
+ animationInQueue: () => boolean;
12
13
  } {
13
14
  const animationQueue = React.useRef<VoidFunction[]>([]);
14
15
 
@@ -33,7 +34,12 @@ export function useSlideAnimation(): {
33
34
  }
34
35
  }
35
36
 
37
+ function animationInQueue() {
38
+ return !!animationQueue.current.length;
39
+ }
40
+
36
41
  return {
42
+ animationInQueue,
37
43
  getAnimateFunction,
38
44
  addToAnimationQueue,
39
45
  startAnimation,
@@ -94,8 +94,10 @@ const FetchingStatus = ({
94
94
  if (fetching) {
95
95
  setStatus('fetching');
96
96
  } else {
97
- setStatus('loaded');
98
- setTimeout(() => setStatus('none'), FETCH_STATUS_RESET_DELAY);
97
+ if (status === 'fetching') {
98
+ setStatus('loaded');
99
+ setTimeout(() => setStatus('none'), FETCH_STATUS_RESET_DELAY);
100
+ }
99
101
  }
100
102
  },
101
103
  [fetching],
@@ -37,6 +37,6 @@
37
37
  overflow: hidden;
38
38
  white-space: nowrap;
39
39
  border: 0 none;
40
- clip-path: rect(0 0 0 0);
40
+ clip-path: inset(50%);
41
41
  direction: ltr;
42
42
  }