@envive-ai/react-toolkit-v3 0.3.8 → 0.3.10
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/dist/AnimatedText/AnimatedText.cjs +1 -0
- package/dist/AnimatedText/AnimatedText.d.cts +3 -3
- package/dist/AnimatedText/AnimatedText.js +1 -0
- package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.cts +2 -2
- package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.ts +2 -2
- package/dist/Carousel/Carousel.cjs +1 -1
- package/dist/Carousel/Carousel.d.cts +2 -2
- package/dist/Carousel/Carousel.d.ts +2 -2
- package/dist/Carousel/Carousel.js +1 -1
- package/dist/Carousel/components/Container.cjs +2 -2
- package/dist/Carousel/components/Container.js +2 -2
- package/dist/ChatFooter/ChatFooter.cjs +1 -1
- package/dist/ChatFooter/ChatFooter.d.cts +2 -2
- package/dist/ChatFooter/ChatFooter.d.ts +2 -2
- package/dist/ChatFooter/ChatFooter.js +1 -1
- package/dist/ChatFooter/components/Layout.cjs +2 -2
- package/dist/ChatFooter/components/Layout.js +2 -2
- package/dist/ChatFooter/components/index.d.cts +5 -5
- package/dist/ChatFooter/components/index.d.ts +5 -5
- package/dist/ChatHeader/ChatHeader.d.cts +2 -2
- package/dist/ChatHeader/ChatHeader.d.ts +2 -2
- package/dist/ChatHeader/components/Handle.cjs +2 -2
- package/dist/ChatHeader/components/Handle.js +2 -2
- package/dist/ChatHeader/components/Toggle.cjs +3 -3
- package/dist/ChatHeader/components/Toggle.js +3 -3
- package/dist/ChatHeader/hooks/useGetCloseButtonProperties.cjs +1 -1
- package/dist/ChatHeader/hooks/useGetCloseButtonProperties.js +1 -1
- package/dist/ChatPreview/ChatPreview.cjs +14 -4
- package/dist/ChatPreview/ChatPreview.d.cts +2 -2
- package/dist/ChatPreview/ChatPreview.d.ts +2 -2
- package/dist/ChatPreview/ChatPreview.js +14 -4
- package/dist/ChatPreview/types/types.d.cts +5 -4
- package/dist/ChatPreview/types/types.d.ts +5 -4
- package/dist/ChatPreviewComparison/ChatPreviewComparison.cjs +14 -4
- package/dist/ChatPreviewComparison/ChatPreviewComparison.d.cts +2 -2
- package/dist/ChatPreviewComparison/ChatPreviewComparison.d.ts +2 -2
- package/dist/ChatPreviewComparison/ChatPreviewComparison.js +14 -4
- package/dist/ChatPreviewComparison/components/Headline.cjs +2 -2
- package/dist/ChatPreviewComparison/components/Headline.js +2 -2
- package/dist/ChatPreviewComparison/components/Layout.cjs +4 -4
- package/dist/ChatPreviewComparison/components/Layout.js +4 -4
- package/dist/ChatPreviewComparison/components/Message.cjs +2 -2
- package/dist/ChatPreviewComparison/components/Message.js +2 -2
- package/dist/ChatPreviewComparison/types/types.d.cts +4 -4
- package/dist/ChatPreviewComparison/types/types.d.ts +4 -4
- package/dist/ChatPreviewLoading/ChatPreviewLoading.d.cts +2 -2
- package/dist/Container/Container.d.cts +5 -5
- package/dist/Container/Container.d.ts +176 -176
- package/dist/DesignTokens/DesignTokensComponent.d.cts +2 -2
- package/dist/DesignTokens/DesignTokensComponent.d.ts +2 -2
- package/dist/Disclaimer/components/Container.cjs +2 -2
- package/dist/Disclaimer/components/Container.js +2 -2
- package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.cts +2 -2
- package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.ts +2 -2
- package/dist/DocumentRetrievalCard/components/Layout.cjs +2 -2
- package/dist/DocumentRetrievalCard/components/Layout.js +2 -2
- package/dist/DocumentRetrievalCard/components/ViewArticleButton/components/Icon.cjs +1 -1
- package/dist/DocumentRetrievalCard/components/ViewArticleButton/components/Icon.js +1 -1
- package/dist/FloatingButton/FloatingButton.d.cts +2 -2
- package/dist/FloatingChat/FloatingChat.cjs +3 -2
- package/dist/FloatingChat/FloatingChat.d.cts +2 -2
- package/dist/FloatingChat/FloatingChat.d.ts +2 -2
- package/dist/FloatingChat/FloatingChat.js +3 -2
- package/dist/FloatingChat/components/AgentMessage.cjs +9 -5
- package/dist/FloatingChat/components/AgentMessage.js +9 -5
- package/dist/FloatingChat/components/ChatMessages.cjs +1 -1
- package/dist/FloatingChat/components/ChatMessages.js +1 -1
- package/dist/FloatingChat/components/Layout.cjs +13 -13
- package/dist/FloatingChat/components/Layout.js +13 -13
- package/dist/FloatingChat/components/ModalSheet.cjs +5 -6
- package/dist/FloatingChat/components/ModalSheet.js +5 -6
- package/dist/FloatingChat/components/ReviewCardsCarousel.cjs +2 -1
- package/dist/FloatingChat/components/ReviewCardsCarousel.js +2 -1
- package/dist/FloatingChat/components/SalesAgentProductCardsCarousel.cjs +0 -3
- package/dist/FloatingChat/components/SalesAgentProductCardsCarousel.js +0 -3
- package/dist/Image/Image.d.cts +2 -2
- package/dist/Image/Image.d.ts +2 -2
- package/dist/ImageGallery/ImageGallery.d.cts +2 -2
- package/dist/ImageGallery/ImageGallery.d.ts +2 -2
- package/dist/ImageGallery/components/Layout.cjs +1 -1
- package/dist/ImageGallery/components/Layout.js +1 -1
- package/dist/MarkdownProcessor/MarkdownProcessor.d.cts +2 -2
- package/dist/MarkdownProcessor/MarkdownProcessor.d.ts +2 -2
- package/dist/Message/components/LinkButton.cjs +1 -1
- package/dist/Message/components/LinkButton.js +1 -1
- package/dist/OrderLookupCard/OrderLookupCard.cjs +1 -1
- package/dist/OrderLookupCard/OrderLookupCard.js +1 -1
- package/dist/ProductCard/ProductCard.cjs +10 -6
- package/dist/ProductCard/ProductCard.d.cts +2 -2
- package/dist/ProductCard/ProductCard.d.ts +2 -2
- package/dist/ProductCard/ProductCard.js +5 -2
- package/dist/ProductCard/components/Header.cjs +2 -2
- package/dist/ProductCard/components/Header.js +2 -2
- package/dist/PromptButton/PromptButton.d.cts +2 -2
- package/dist/PromptButton/PromptButton.d.ts +2 -2
- package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.cjs +3 -2
- package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.cts +2 -2
- package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.ts +2 -2
- package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.js +3 -2
- package/dist/PromptButtonCarouselWithImage/components/Layout.cjs +7 -2
- package/dist/PromptButtonCarouselWithImage/components/Layout.js +8 -3
- package/dist/PromptButtonCarouselWithImage/components/PromptButtonsCarousel.cjs +53 -3
- package/dist/PromptButtonCarouselWithImage/components/PromptButtonsCarousel.js +53 -3
- package/dist/PromptCarousel/PromptCarousel.cjs +71 -33
- package/dist/PromptCarousel/PromptCarousel.d.cts +2 -2
- package/dist/PromptCarousel/PromptCarousel.d.ts +2 -2
- package/dist/PromptCarousel/PromptCarousel.js +73 -35
- package/dist/PromptCarousel/hooks/index.cjs +2 -4
- package/dist/PromptCarousel/hooks/index.js +2 -4
- package/dist/PromptCarousel/hooks/useCoordinatedScrollAnimation.cjs +91 -0
- package/dist/PromptCarousel/hooks/useCoordinatedScrollAnimation.js +90 -0
- package/dist/PromptCarousel/hooks/useScrollSync.cjs +65 -0
- package/dist/PromptCarousel/hooks/useScrollSync.js +64 -0
- package/dist/ReviewCard/ReviewCard.d.cts +2 -2
- package/dist/ReviewCard/ReviewCard.d.ts +2 -2
- package/dist/ReviewCard/components/Container.cjs +2 -2
- package/dist/ReviewCard/components/Container.js +2 -2
- package/dist/ReviewCard/components/ReadMoreButton.cjs +1 -1
- package/dist/ReviewCard/components/ReadMoreButton.js +1 -1
- package/dist/ReviewCard/components/index.d.cts +4 -4
- package/dist/ReviewCard/components/index.d.ts +6 -6
- package/dist/SalesAgentProductCard/SalesAgentProductCard.d.cts +2 -2
- package/dist/SalesAgentProductCard/SalesAgentProductCard.d.ts +2 -2
- package/dist/SalesAgentProductCard/components/Container.cjs +2 -2
- package/dist/SalesAgentProductCard/components/Container.js +2 -2
- package/dist/SalesAgentProductCard/components/index.d.cts +6 -6
- package/dist/SalesAgentProductCard/components/index.d.ts +8 -8
- package/dist/SocialProof/SocialProof.cjs +1 -1
- package/dist/SocialProof/SocialProof.d.cts +2 -2
- package/dist/SocialProof/SocialProof.d.ts +2 -2
- package/dist/SocialProof/SocialProof.js +1 -1
- package/dist/SocialProof/components/Headline.cjs +3 -3
- package/dist/SocialProof/components/Headline.js +3 -3
- package/dist/SocialProof/components/LayoutFourHorizontal.cjs +1 -1
- package/dist/SocialProof/components/LayoutFourHorizontal.js +1 -1
- package/dist/SocialProof/components/Subheadline.cjs +1 -1
- package/dist/SocialProof/components/Subheadline.js +1 -1
- package/dist/Stack/Stack.d.cts +2 -2
- package/dist/TextField/utils/getIconColor.cjs +1 -1
- package/dist/TextField/utils/getIconColor.js +1 -1
- package/dist/TextField/utils/getSendIconElement.cjs +1 -1
- package/dist/TextField/utils/getSendIconElement.js +1 -1
- package/dist/TitledPromptCarousel/TitledPromptCarousel.cjs +1 -1
- package/dist/TitledPromptCarousel/TitledPromptCarousel.d.cts +2 -2
- package/dist/TitledPromptCarousel/TitledPromptCarousel.d.ts +2 -2
- package/dist/TitledPromptCarousel/TitledPromptCarousel.js +1 -1
- package/dist/Tokens/index.cjs +1 -1
- package/dist/Tokens/index.js +1 -1
- package/dist/TypingAnimation/TypingAnimation.cjs +1 -1
- package/dist/TypingAnimation/TypingAnimation.d.cts +2 -2
- package/dist/TypingAnimation/TypingAnimation.d.ts +2 -2
- package/dist/TypingAnimation/TypingAnimation.js +1 -1
- package/dist/TypingAnimation/hooks/useGetTypographyVariant.cjs +1 -1
- package/dist/TypingAnimation/hooks/useGetTypographyVariant.js +1 -1
- package/dist/Typography/Typography.d.cts +4 -4
- package/dist/Typography/Typography.d.ts +4 -4
- package/dist/WelcomeMessage/components/Container.cjs +2 -2
- package/dist/WelcomeMessage/components/Container.js +2 -2
- package/dist/WidgetTextField/WidgetTextField.cjs +11 -6
- package/dist/WidgetTextField/WidgetTextField.d.cts +3 -2
- package/dist/WidgetTextField/WidgetTextField.d.ts +3 -2
- package/dist/WidgetTextField/WidgetTextField.js +7 -2
- package/dist/WidgetTextField/components/Container.cjs +2 -2
- package/dist/WidgetTextField/components/Container.js +2 -2
- package/dist/WidgetTextField/components/FakeTextInput.cjs +2 -2
- package/dist/WidgetTextField/components/FakeTextInput.js +2 -2
- package/dist/WidgetTextField/components/Icon.cjs +11 -9
- package/dist/WidgetTextField/components/Icon.js +11 -9
- package/dist/WidgetTextField/types/types.d.cts +3 -0
- package/dist/WidgetTextField/types/types.d.ts +3 -0
- package/dist/WidgetWrapper/WidgetWrapper.d.cts +2 -2
- package/dist/WidgetWrapper/WidgetWrapper.d.ts +2 -2
- package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.cts +2 -2
- package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.ts +2 -2
- package/dist/styles.css +1 -1
- package/dist/utils/CustomIcon.cjs +1 -1
- package/dist/utils/CustomIcon.js +1 -1
- package/dist/utils/useDragToScroll.cjs +68 -0
- package/dist/utils/useDragToScroll.js +67 -0
- package/package.json +1 -1
- package/src/components/AnimatedText/AnimatedText.tsx +2 -0
- package/src/components/ChatHeader/hooks/useGetCloseButtonProperties.ts +1 -1
- package/src/components/ChatPreview/ChatPreview.tsx +20 -3
- package/src/components/ChatPreview/types/types.ts +5 -4
- package/src/components/ChatPreviewComparison/ChatPreviewComparison.tsx +20 -3
- package/src/components/ChatPreviewComparison/types/types.ts +4 -4
- package/src/components/FloatingChat/FloatingChat.tsx +3 -2
- package/src/components/FloatingChat/components/AgentMessage.tsx +1 -0
- package/src/components/FloatingChat/components/Layout.tsx +7 -2
- package/src/components/FloatingChat/components/ModalSheet.tsx +5 -7
- package/src/components/FloatingChat/components/ReviewCardsCarousel.tsx +3 -0
- package/src/components/FloatingChat/components/SalesAgentProductCardsCarousel.tsx +0 -3
- package/src/components/ProductCard/ProductCard.tsx +12 -1
- package/src/components/ProductCard/components/Header.tsx +10 -8
- package/src/components/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.tsx +6 -3
- package/src/components/PromptButtonCarouselWithImage/components/Layout.tsx +13 -4
- package/src/components/PromptButtonCarouselWithImage/components/PromptButtonsCarousel.tsx +63 -20
- package/src/components/PromptCarousel/PromptCarousel.tsx +89 -51
- package/src/components/PromptCarousel/hooks/index.ts +2 -4
- package/src/components/PromptCarousel/hooks/useCoordinatedScrollAnimation.ts +115 -0
- package/src/components/PromptCarousel/hooks/useHorizontalScrollAnimation.ts +71 -78
- package/src/components/PromptCarousel/hooks/useScrollSync.ts +83 -0
- package/src/components/TextField/utils/getIconColor.ts +1 -1
- package/src/components/TextField/utils/getSendIconElement.tsx +3 -1
- package/src/components/WidgetTextField/WidgetTextField.tsx +9 -1
- package/src/components/WidgetTextField/components/FakeTextInput.tsx +6 -2
- package/src/components/WidgetTextField/components/Icon.tsx +44 -9
- package/src/components/WidgetTextField/types/types.ts +3 -0
- package/src/components/utils/CustomIcon.tsx +1 -1
- package/src/components/utils/useDragToScroll.ts +83 -0
- package/dist/PromptCarousel/components/BlockScrollContainer.cjs +0 -23
- package/dist/PromptCarousel/components/BlockScrollContainer.js +0 -21
- package/dist/PromptCarousel/components/ButtonContainerRow.cjs +0 -34
- package/dist/PromptCarousel/components/ButtonContainerRow.js +0 -32
- package/dist/PromptCarousel/components/CarouselContentWithBlockScroll.cjs +0 -45
- package/dist/PromptCarousel/components/CarouselContentWithBlockScroll.js +0 -44
- package/dist/PromptCarousel/components/CarouselContentWithRowScroll.cjs +0 -33
- package/dist/PromptCarousel/components/CarouselContentWithRowScroll.js +0 -32
- package/dist/PromptCarousel/components/index.cjs +0 -13
- package/dist/PromptCarousel/components/index.js +0 -13
- package/dist/PromptCarousel/hooks/useButtonScrollPosition.cjs +0 -79
- package/dist/PromptCarousel/hooks/useButtonScrollPosition.js +0 -78
- package/dist/PromptCarousel/hooks/useCarouselAnimation.cjs +0 -23
- package/dist/PromptCarousel/hooks/useCarouselAnimation.js +0 -22
- package/dist/PromptCarousel/hooks/useCarouselRefs.cjs +0 -20
- package/dist/PromptCarousel/hooks/useCarouselRefs.js +0 -19
- package/dist/PromptCarousel/hooks/useGetScrollProperties.cjs +0 -18
- package/dist/PromptCarousel/hooks/useGetScrollProperties.js +0 -17
- package/dist/PromptCarousel/hooks/useHorizontalScrollAnimation.cjs +0 -78
- package/dist/PromptCarousel/hooks/useHorizontalScrollAnimation.js +0 -77
- package/src/components/PromptCarousel/components/BlockScrollContainer.tsx +0 -34
- package/src/components/PromptCarousel/components/ButtonContainerRow.tsx +0 -46
- package/src/components/PromptCarousel/components/CarouselContentWithBlockScroll.tsx +0 -83
- package/src/components/PromptCarousel/components/CarouselContentWithRowScroll.tsx +0 -71
- package/src/components/PromptCarousel/components/index.ts +0 -9
- package/src/components/PromptCarousel/hooks/useButtonScrollPosition.ts +0 -128
- package/src/components/PromptCarousel/hooks/useCarouselAnimation.ts +0 -47
- package/src/components/PromptCarousel/hooks/useCarouselRefs.ts +0 -27
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
-
import { RepetitionNumberSuffix } from '../types/types';
|
|
3
|
-
|
|
4
|
-
const getElementId = (element: Element | null): string | null => {
|
|
5
|
-
if (!element) return null;
|
|
6
|
-
return element.id?.trim() || null;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export function useButtonScrollPosition(
|
|
10
|
-
firstRowScrollRef: React.RefObject<HTMLDivElement>,
|
|
11
|
-
blockScrollRef: React.RefObject<HTMLDivElement>,
|
|
12
|
-
shouldUseRowScroll: boolean,
|
|
13
|
-
) {
|
|
14
|
-
const savedButtonIdRef = useRef<string | null>(null);
|
|
15
|
-
const savedButtonPositionRef = useRef<number | null>(null);
|
|
16
|
-
|
|
17
|
-
const captureButtonUnderMouse = useCallback(
|
|
18
|
-
(mouseX: number, mouseY: number) => {
|
|
19
|
-
const container = firstRowScrollRef.current;
|
|
20
|
-
if (!container) return;
|
|
21
|
-
|
|
22
|
-
const containerRect = container.getBoundingClientRect();
|
|
23
|
-
|
|
24
|
-
const elementUnderMouse = document.elementFromPoint(mouseX, mouseY);
|
|
25
|
-
const targetButtonId = getElementId(elementUnderMouse);
|
|
26
|
-
|
|
27
|
-
let closestButton: HTMLElement | null = null;
|
|
28
|
-
|
|
29
|
-
if (targetButtonId) {
|
|
30
|
-
const buttonById = document.querySelector(`#${CSS.escape(targetButtonId)}`) as HTMLElement;
|
|
31
|
-
if (
|
|
32
|
-
buttonById &&
|
|
33
|
-
(elementUnderMouse === buttonById || buttonById.contains(elementUnderMouse as Node))
|
|
34
|
-
) {
|
|
35
|
-
closestButton = buttonById;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!closestButton) {
|
|
40
|
-
const buttons = Array.from(container.querySelectorAll('button')) as HTMLElement[];
|
|
41
|
-
let closestDistance = Infinity;
|
|
42
|
-
|
|
43
|
-
for (const button of buttons) {
|
|
44
|
-
const buttonRect = button.getBoundingClientRect();
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
mouseX >= buttonRect.left &&
|
|
48
|
-
mouseX <= buttonRect.right &&
|
|
49
|
-
mouseY >= buttonRect.top &&
|
|
50
|
-
mouseY <= buttonRect.bottom
|
|
51
|
-
) {
|
|
52
|
-
closestButton = button;
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const buttonCenterX = buttonRect.left + buttonRect.width / 2;
|
|
57
|
-
const buttonCenterY = buttonRect.top + buttonRect.height / 2;
|
|
58
|
-
const distance = Math.sqrt((mouseX - buttonCenterX) ** 2 + (mouseY - buttonCenterY) ** 2);
|
|
59
|
-
|
|
60
|
-
if (distance < closestDistance) {
|
|
61
|
-
closestDistance = distance;
|
|
62
|
-
closestButton = button;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (closestButton) {
|
|
68
|
-
const id = getElementId(closestButton);
|
|
69
|
-
if (id) {
|
|
70
|
-
savedButtonIdRef.current = id;
|
|
71
|
-
const buttonRect = closestButton.getBoundingClientRect();
|
|
72
|
-
savedButtonPositionRef.current = buttonRect.left - containerRect.left;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
[firstRowScrollRef],
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
if (
|
|
81
|
-
shouldUseRowScroll ||
|
|
82
|
-
!blockScrollRef.current ||
|
|
83
|
-
!savedButtonIdRef.current ||
|
|
84
|
-
savedButtonPositionRef.current === null
|
|
85
|
-
) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const container = blockScrollRef.current;
|
|
90
|
-
const targetId = savedButtonIdRef.current.trim();
|
|
91
|
-
const targetPosition = savedButtonPositionRef.current;
|
|
92
|
-
|
|
93
|
-
const getScrollId = (id: string) => {
|
|
94
|
-
if (id.endsWith(RepetitionNumberSuffix.TWO)) {
|
|
95
|
-
return id;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (id.endsWith(RepetitionNumberSuffix.THREE)) {
|
|
99
|
-
return `${id.slice(0, -2)}${RepetitionNumberSuffix.TWO}`;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return `${id}${RepetitionNumberSuffix.TWO}`;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const applyScroll = () => {
|
|
106
|
-
const finalId = getScrollId(targetId);
|
|
107
|
-
const targetButton = container.querySelector(`#${CSS.escape(`${finalId}`)}`) as HTMLElement;
|
|
108
|
-
const scrollableContent = container.firstElementChild as HTMLElement;
|
|
109
|
-
|
|
110
|
-
if (!targetButton || !scrollableContent) return;
|
|
111
|
-
|
|
112
|
-
const contentRect = scrollableContent.getBoundingClientRect();
|
|
113
|
-
const buttonRect = targetButton.getBoundingClientRect();
|
|
114
|
-
const buttonPositionInContent = buttonRect.left - contentRect.left + container.scrollLeft;
|
|
115
|
-
const newScrollLeft = buttonPositionInContent - targetPosition;
|
|
116
|
-
|
|
117
|
-
container.scrollLeft = Math.max(0, newScrollLeft);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
requestAnimationFrame(() => {
|
|
121
|
-
requestAnimationFrame(() => {
|
|
122
|
-
requestAnimationFrame(applyScroll);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
}, [shouldUseRowScroll, blockScrollRef]);
|
|
126
|
-
|
|
127
|
-
return { captureButtonUnderMouse };
|
|
128
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState } from 'react';
|
|
2
|
-
import { AnimationSpeed } from '../types/types';
|
|
3
|
-
import { useButtonScrollPosition } from './useButtonScrollPosition';
|
|
4
|
-
import { useHorizontalScrollAnimation } from './useHorizontalScrollAnimation';
|
|
5
|
-
|
|
6
|
-
interface UseCarouselAnimationProps {
|
|
7
|
-
firstRowScrollRef: React.RefObject<HTMLDivElement>;
|
|
8
|
-
blockScrollRef: React.RefObject<HTMLDivElement>;
|
|
9
|
-
scrollRefs: React.RefObject<HTMLDivElement>[];
|
|
10
|
-
animationSpeed: `${AnimationSpeed}`;
|
|
11
|
-
isAnimated: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const useCarouselAnimation = ({
|
|
15
|
-
firstRowScrollRef,
|
|
16
|
-
blockScrollRef,
|
|
17
|
-
scrollRefs,
|
|
18
|
-
animationSpeed,
|
|
19
|
-
isAnimated,
|
|
20
|
-
}: UseCarouselAnimationProps) => {
|
|
21
|
-
const [isAnimationStopped, setIsAnimationStopped] = useState(false);
|
|
22
|
-
const shouldUseRowScroll = isAnimated && !isAnimationStopped;
|
|
23
|
-
|
|
24
|
-
const { captureButtonUnderMouse } = useButtonScrollPosition(
|
|
25
|
-
firstRowScrollRef,
|
|
26
|
-
blockScrollRef,
|
|
27
|
-
shouldUseRowScroll,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const onStopAll = useCallback(
|
|
31
|
-
(mouseX?: number, mouseY?: number) => {
|
|
32
|
-
if (mouseX !== undefined && mouseY !== undefined) {
|
|
33
|
-
captureButtonUnderMouse(mouseX, mouseY);
|
|
34
|
-
}
|
|
35
|
-
setIsAnimationStopped(true);
|
|
36
|
-
},
|
|
37
|
-
[captureButtonUnderMouse],
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
useHorizontalScrollAnimation(
|
|
41
|
-
scrollRefs,
|
|
42
|
-
onStopAll,
|
|
43
|
-
shouldUseRowScroll ? animationSpeed : AnimationSpeed.NONE,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
return { isAnimationStopped, shouldUseRowScroll };
|
|
47
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { useMemo, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
interface UseCarouselRefsProps {
|
|
4
|
-
shouldShowTwoRows: boolean;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const useCarouselRefs = ({ shouldShowTwoRows }: UseCarouselRefsProps) => {
|
|
8
|
-
const firstRowScrollRef = useRef<HTMLDivElement>(null);
|
|
9
|
-
const firstRowStackRef = useRef<HTMLDivElement>(null);
|
|
10
|
-
const secondRowScrollRef = useRef<HTMLDivElement>(null);
|
|
11
|
-
const blockScrollRef = useRef<HTMLDivElement>(null);
|
|
12
|
-
const blockFirstRowStackRef = useRef<HTMLDivElement>(null);
|
|
13
|
-
|
|
14
|
-
const scrollRefs = useMemo(
|
|
15
|
-
() => (shouldShowTwoRows ? [firstRowScrollRef, secondRowScrollRef] : [firstRowScrollRef]),
|
|
16
|
-
[shouldShowTwoRows],
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
firstRowScrollRef,
|
|
21
|
-
firstRowStackRef,
|
|
22
|
-
secondRowScrollRef,
|
|
23
|
-
blockScrollRef,
|
|
24
|
-
blockFirstRowStackRef,
|
|
25
|
-
scrollRefs,
|
|
26
|
-
};
|
|
27
|
-
};
|