@onepercentio/one-ui 0.29.2 → 0.29.5
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/components/Switch/Switch.d.ts +1 -1
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/hooks/useHero.js +3 -2
- package/dist-ts/components/Switch/Switch.d.ts +1 -1
- package/dist-ts/hooks/useHero.js +5 -4
- package/dist-ts/hooks/useHero.js.map +1 -1
- package/package.json +5 -1
- package/src/assets/img/svg/checkbox.svg +0 -3
- package/src/assets/styles/index.scss +0 -2
- package/src/assets/styles/mixins.scss +0 -12
- package/src/assets/styles/variables.scss +0 -49
- package/src/components/AdaptiveButton/AdaptiveButton.module.scss +0 -7
- package/src/components/AdaptiveButton/AdaptiveButton.tsx +0 -26
- package/src/components/AdaptiveButton/index.tsx +0 -2
- package/src/components/AdaptiveContainer/AdaptiveContainer.module.scss +0 -53
- package/src/components/AdaptiveContainer/AdaptiveContainer.tsx +0 -200
- package/src/components/AdaptiveContainer/index.tsx +0 -2
- package/src/components/AdaptiveDialog/AdaptiveDialog.module.scss +0 -147
- package/src/components/AdaptiveDialog/AdaptiveDialog.tsx +0 -97
- package/src/components/AdaptiveDialog/index.tsx +0 -2
- package/src/components/AdaptiveSidebar/AdaptiveSidebar.module.scss +0 -49
- package/src/components/AdaptiveSidebar/AdaptiveSidebar.sample.tsx +0 -10
- package/src/components/AdaptiveSidebar/AdaptiveSidebar.tsx +0 -123
- package/src/components/AdaptiveSidebar/index.tsx +0 -2
- package/src/components/AnchoredTooltip/AnchoredTooltip.module.scss +0 -64
- package/src/components/AnchoredTooltip/AnchoredTooltip.tsx +0 -250
- package/src/components/AnchoredTooltip/index.tsx +0 -2
- package/src/components/AnimatedEntrance/AnimatedEntrance.module.scss +0 -108
- package/src/components/AnimatedEntrance/AnimatedEntrance.tsx +0 -227
- package/src/components/AnimatedEntrance/index.tsx +0 -2
- package/src/components/AsyncWrapper/AsyncWrapper.tsx +0 -38
- package/src/components/AsyncWrapper/index.tsx +0 -2
- package/src/components/Avatar/Avatar.module.scss +0 -22
- package/src/components/Avatar/Avatar.tsx +0 -31
- package/src/components/Avatar/index.tsx +0 -2
- package/src/components/BucketFill/BucketFill.module.scss +0 -36
- package/src/components/BucketFill/BucketFill.tsx +0 -65
- package/src/components/BucketFill/index.tsx +0 -2
- package/src/components/Button/Button.module.scss +0 -45
- package/src/components/Button/Button.tsx +0 -40
- package/src/components/Button/index.tsx +0 -2
- package/src/components/Card/Card.module.scss +0 -12
- package/src/components/Card/Card.tsx +0 -9
- package/src/components/Card/index.tsx +0 -2
- package/src/components/Chart/Chart.e2e.ts +0 -4
- package/src/components/Chart/Chart.logic.tsx +0 -8
- package/src/components/Chart/Chart.module.scss +0 -58
- package/src/components/Chart/Chart.tsx +0 -2
- package/src/components/Chart/Chart.types.ts +0 -35
- package/src/components/Chart/Chart.view.tsx +0 -241
- package/src/components/Chart/index.tsx +0 -2
- package/src/components/CheckBox/CheckBox.module.scss +0 -36
- package/src/components/CheckBox/CheckBox.tsx +0 -63
- package/src/components/CheckBox/index.tsx +0 -2
- package/src/components/CodeInput/CodeInput.module.scss +0 -5
- package/src/components/CodeInput/CodeInput.tsx +0 -84
- package/src/components/CodeInput/index.tsx +0 -2
- package/src/components/Collapsable/Collapsable.module.scss +0 -42
- package/src/components/Collapsable/Collapsable.tsx +0 -253
- package/src/components/Collapsable/index.tsx +0 -2
- package/src/components/Countdown/Countdown.tsx +0 -130
- package/src/components/Countdown/index.tsx +0 -2
- package/src/components/CurrencyInput/CurrencyInput.hook.ts +0 -37
- package/src/components/CurrencyInput/CurrencyInput.tsx +0 -25
- package/src/components/CurrencyInput/index.tsx +0 -2
- package/src/components/Divider/Divider.module.scss +0 -7
- package/src/components/Divider/Divider.tsx +0 -13
- package/src/components/Divider/index.tsx +0 -2
- package/src/components/EmailInput/EmailInput.module.scss +0 -0
- package/src/components/EmailInput/EmailInput.tsx +0 -51
- package/src/components/EmailInput/index.tsx +0 -2
- package/src/components/FadeIn/FadeIn.module.scss +0 -9
- package/src/components/FadeIn/FadeIn.tsx +0 -77
- package/src/components/FadeIn/index.tsx +0 -2
- package/src/components/FileInput/FileInput.module.scss +0 -6
- package/src/components/FileInput/FileInput.tsx +0 -75
- package/src/components/FileInput/View/BigFactory/BigFactory.module.scss +0 -20
- package/src/components/FileInput/View/BigFactory/BigFactory.tsx +0 -48
- package/src/components/FileInput/View/BigFactory/index.tsx +0 -2
- package/src/components/FileInput/View/Compact/Compact.module.scss +0 -68
- package/src/components/FileInput/View/Compact/Compact.tsx +0 -151
- package/src/components/FileInput/View/Compact/index.tsx +0 -2
- package/src/components/FileInput/View/View.types.ts +0 -12
- package/src/components/FileInput/index.tsx +0 -2
- package/src/components/FlowController/FlowController.module.scss +0 -47
- package/src/components/FlowController/FlowController.tsx +0 -93
- package/src/components/FlowController/index.tsx +0 -2
- package/src/components/Form/Form.tsx +0 -243
- package/src/components/Form/index.ts +0 -2
- package/src/components/Form/v2/Form.hook.ts +0 -341
- package/src/components/Form/v2/Form.module.scss +0 -0
- package/src/components/Form/v2/Form.tsx +0 -78
- package/src/components/Form/v2/Form.types.ts +0 -118
- package/src/components/Form/v2/FormField/Extensions/DateField/DateField.module.scss +0 -0
- package/src/components/Form/v2/FormField/Extensions/DateField/DateField.tsx +0 -73
- package/src/components/Form/v2/FormField/Extensions/DateField/index.tsx +0 -2
- package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.module.scss +0 -0
- package/src/components/Form/v2/FormField/Extensions/PhoneField/PhoneField.tsx +0 -91
- package/src/components/Form/v2/FormField/Extensions/PhoneField/index.tsx +0 -2
- package/src/components/Form/v2/FormField/FormField.module.scss +0 -0
- package/src/components/Form/v2/FormField/FormField.tsx +0 -378
- package/src/components/Form/v2/FormField/FormField.types.ts +0 -129
- package/src/components/Form/v2/FormField/index.tsx +0 -2
- package/src/components/Form/v2/index.tsx +0 -2
- package/src/components/Freeze/Freeze.tsx +0 -9
- package/src/components/Freeze/index.tsx +0 -2
- package/src/components/HSForms/HSForms.tsx +0 -57
- package/src/components/HSForms/index.tsx +0 -2
- package/src/components/Header/Header.module.scss +0 -119
- package/src/components/Header/Header.tsx +0 -138
- package/src/components/Header/index.tsx +0 -2
- package/src/components/HeaderCloseBtn/HeaderCloseBtn.module.scss +0 -44
- package/src/components/HeaderCloseBtn/HeaderCloseBtn.tsx +0 -28
- package/src/components/HeaderCloseBtn/index.tsx +0 -2
- package/src/components/InfinityScroll/InfinityScroll.module.scss +0 -30
- package/src/components/InfinityScroll/InfinityScroll.tsx +0 -187
- package/src/components/InfinityScroll/index.tsx +0 -2
- package/src/components/Input/Input.module.scss +0 -71
- package/src/components/Input/Input.tsx +0 -134
- package/src/components/Input/index.tsx +0 -2
- package/src/components/InstantCounter/InstantCounter.tsx +0 -77
- package/src/components/InstantCounter/index.tsx +0 -2
- package/src/components/LavaLamp/LavaLamp.data.tsx +0 -114
- package/src/components/LavaLamp/LavaLamp.module.scss +0 -26
- package/src/components/LavaLamp/LavaLamp.tsx +0 -131
- package/src/components/LavaLamp/index.tsx +0 -2
- package/src/components/LavaLamp/v2/LavaLamp.module.scss +0 -23
- package/src/components/LavaLamp/v2/LavaLamp.tsx +0 -197
- package/src/components/LinkToId/LinkToId.module.scss +0 -4
- package/src/components/LinkToId/LinkToId.tsx +0 -51
- package/src/components/LinkToId/index.tsx +0 -2
- package/src/components/Loader/Loader.module.scss +0 -40
- package/src/components/Loader/Loader.tsx +0 -18
- package/src/components/Loader/index.tsx +0 -2
- package/src/components/LoaderDotsIndicator/LoaderDotsIndicator.tsx +0 -34
- package/src/components/LoaderDotsIndicator/index.tsx +0 -2
- package/src/components/LoopableVideo/LoopableVideo.tsx +0 -37
- package/src/components/LoopableVideo/index.tsx +0 -2
- package/src/components/MainGrid/MainGrid.module.scss +0 -28
- package/src/components/MainGrid/MainGrid.tsx +0 -68
- package/src/components/MainGrid/index.tsx +0 -2
- package/src/components/MutableHamburgerButton/MutableHamburgerButton.module.scss +0 -220
- package/src/components/MutableHamburgerButton/MutableHamburgerButton.tsx +0 -38
- package/src/components/MutableHamburgerButton/index.tsx +0 -2
- package/src/components/Notification/Notification.module.scss +0 -25
- package/src/components/Notification/Notification.tsx +0 -13
- package/src/components/Notification/index.tsx +0 -2
- package/src/components/OrderableList/OrderableList.module.scss +0 -98
- package/src/components/OrderableList/OrderableList.tsx +0 -564
- package/src/components/OrderableList/index.tsx +0 -2
- package/src/components/PaginationIndicator/PaginationIndicator.tsx +0 -365
- package/src/components/PaginationIndicator/index.tsx +0 -2
- package/src/components/Parallax/Parallax.module.scss +0 -28
- package/src/components/Parallax/Parallax.tsx +0 -225
- package/src/components/Parallax/index.tsx +0 -2
- package/src/components/Parallax/math/helpers.ts +0 -289
- package/src/components/PasswordInput/PasswordInput.module.scss +0 -17
- package/src/components/PasswordInput/PasswordInput.tsx +0 -154
- package/src/components/PasswordInput/index.tsx +0 -2
- package/src/components/PingPongText/PingPongText.module.scss +0 -4
- package/src/components/PingPongText/PingPongText.tsx +0 -83
- package/src/components/PingPongText/index.tsx +0 -2
- package/src/components/PixelatedScan/PixelatedScan.module.scss +0 -86
- package/src/components/PixelatedScan/PixelatedScan.tsx +0 -175
- package/src/components/PixelatedScan/index.tsx +0 -2
- package/src/components/Portal/Portal.module.scss +0 -3
- package/src/components/Portal/Portal.tsx +0 -68
- package/src/components/Portal/index.tsx +0 -2
- package/src/components/ProgressBar/ProgressBar.module.scss +0 -44
- package/src/components/ProgressBar/ProgressBar.tsx +0 -124
- package/src/components/ProgressBar/index.tsx +0 -2
- package/src/components/ProgressTexts/ProgressTexts.module.scss +0 -37
- package/src/components/ProgressTexts/ProgressTexts.tsx +0 -85
- package/src/components/ProgressTexts/index.tsx +0 -2
- package/src/components/Radio/Radio.module.scss +0 -36
- package/src/components/Radio/Radio.tsx +0 -53
- package/src/components/Radio/index.tsx +0 -2
- package/src/components/SectionContainer/SectionContainer.module.scss +0 -30
- package/src/components/SectionContainer/SectionContainer.tsx +0 -49
- package/src/components/SectionContainer/index.tsx +0 -2
- package/src/components/Select/Select.module.scss +0 -58
- package/src/components/Select/Select.tsx +0 -192
- package/src/components/Select/index.tsx +0 -2
- package/src/components/Skeleton/Skeleton.module.scss +0 -21
- package/src/components/Skeleton/Skeleton.tsx +0 -29
- package/src/components/Skeleton/index.tsx +0 -2
- package/src/components/Spacing/Spacing.module.scss +0 -13
- package/src/components/Spacing/Spacing.tsx +0 -24
- package/src/components/Spacing/index.tsx +0 -2
- package/src/components/StaticScroller/StaticScroller.module.scss +0 -14
- package/src/components/StaticScroller/StaticScroller.tsx +0 -83
- package/src/components/StaticScroller/index.tsx +0 -2
- package/src/components/Switch/Switch.module.scss +0 -43
- package/src/components/Switch/Switch.tsx +0 -41
- package/src/components/Switch/index.tsx +0 -2
- package/src/components/Table/Table.module.scss +0 -76
- package/src/components/Table/Table.tsx +0 -152
- package/src/components/Table/index.tsx +0 -2
- package/src/components/Tabs/Tabs.module.scss +0 -40
- package/src/components/Tabs/Tabs.tsx +0 -104
- package/src/components/Tabs/index.tsx +0 -2
- package/src/components/Text/Text.module.scss +0 -81
- package/src/components/Text/Text.tsx +0 -42
- package/src/components/Text/index.tsx +0 -2
- package/src/components/Transition/MasksFactory/DiagonalReveal.tsx +0 -47
- package/src/components/Transition/MasksFactory/DiagonalSquareToBalls.tsx +0 -78
- package/src/components/Transition/MasksFactory/PhysicsSquares.tsx +0 -106
- package/src/components/Transition/MasksFactory/SquareToBalls.tsx +0 -66
- package/src/components/Transition/MasksFactory/utils.ts +0 -35
- package/src/components/Transition/Transition.module.scss +0 -211
- package/src/components/Transition/Transition.tsx +0 -495
- package/src/components/Transition/index.tsx +0 -2
- package/src/components/UncontrolledTransition/UncontrolledTransition.ai.md +0 -9
- package/src/components/UncontrolledTransition/UncontrolledTransition.sample.tsx +0 -34
- package/src/components/UncontrolledTransition/UncontrolledTransition.tsx +0 -143
- package/src/components/UncontrolledTransition/index.tsx +0 -2
- package/src/components/WalletConnectionWrapper/WalletConnectionWrapper.tsx +0 -212
- package/src/components/WalletConnectionWrapper/index.tsx +0 -2
- package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.module.scss +0 -5
- package/src/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.tsx +0 -52
- package/src/components/utilitary/ScrollAndFocusLock/index.tsx +0 -2
- package/src/context/AsyncProcess.tsx +0 -107
- package/src/context/ContextAsyncControl.tsx +0 -89
- package/src/context/CustomBrowserRouter.tsx +0 -55
- package/src/context/OneUIProvider.tsx +0 -308
- package/src/hooks/logs/useDependencyChangeDetection.ts +0 -25
- package/src/hooks/logs/useIsMounting.ts +0 -7
- package/src/hooks/persistence/useLocalStorage.ts +0 -45
- package/src/hooks/shims/ObjectWatchShim.ts +0 -56
- package/src/hooks/ui/useAdaptiveImage.tsx +0 -36
- package/src/hooks/ui/useAlternating.tsx +0 -22
- package/src/hooks/ui/useBreakpoint.tsx +0 -21
- package/src/hooks/ui/useCustomScrollbar.module.scss +0 -20
- package/src/hooks/ui/useCustomScrollbar.tsx +0 -22
- package/src/hooks/ui/useEffectIf.ts +0 -11
- package/src/hooks/ui/useMouseHover.tsx +0 -26
- package/src/hooks/ui/usePaginationControls.module.scss +0 -16
- package/src/hooks/ui/usePaginationControls.tsx +0 -176
- package/src/hooks/ui/useSnapToViewport.module.scss +0 -6
- package/src/hooks/ui/useSnapToViewport.ts +0 -28
- package/src/hooks/ui/useTilt.tsx +0 -219
- package/src/hooks/ui/useZoomable.module.scss +0 -34
- package/src/hooks/ui/useZoomable.tsx +0 -144
- package/src/hooks/useAsyncControl.ai.md +0 -25
- package/src/hooks/useAsyncControl.ts +0 -101
- package/src/hooks/useContainedRepositioning.ts +0 -110
- package/src/hooks/useCustomHistory.ts +0 -14
- package/src/hooks/useElementFit.ts +0 -82
- package/src/hooks/useFirestoreWatch.ts +0 -54
- package/src/hooks/useForm.ts +0 -49
- package/src/hooks/useFreeze.ts +0 -12
- package/src/hooks/useHero.module.scss +0 -41
- package/src/hooks/useHero.ts +0 -512
- package/src/hooks/useIntersection.ts +0 -32
- package/src/hooks/useMergeRefs.ts +0 -29
- package/src/hooks/useObserve.ts +0 -24
- package/src/hooks/usePagination.ts +0 -228
- package/src/hooks/usePooledOperation.ts +0 -54
- package/src/hooks/usePooling.ts +0 -46
- package/src/hooks/useRebound.ts +0 -23
- package/src/hooks/useShortIntl.ai.md +0 -5
- package/src/hooks/useShortIntl.ts +0 -97
- package/src/hooks/utility/useAsyncMemo.ts +0 -43
- package/src/hooks/utility/useDepChange.ts +0 -11
- package/src/hooks/utility/useEvents.ts +0 -33
- package/src/hooks/utility/useImmediate.ts +0 -8
- package/src/hooks/utility/useManualInit.ts +0 -24
- package/src/hooks/utility/useModule.ts +0 -15
- package/src/hooks/utility/useQuery.ts +0 -15
- package/src/hooks/utility/useUniqueEffect.ts +0 -22
- package/src/index.preprocess.ts +0 -82
- package/src/index.ts +0 -229
- package/src/models/DebugLogger.ts +0 -7
- package/src/models/GenericContract.ts +0 -169
- package/src/models/Orbs.ts +0 -97
- package/src/reac-app-env.d.ts +0 -6
- package/src/storybook/assets/video/txt-reversed.mp4 +0 -0
- package/src/storybookUtils/index.tsx +0 -53
- package/src/test.tsx +0 -0
- package/src/type-utils.ts +0 -49
- package/src/types.ts +0 -199
- package/src/utility.d.ts +0 -70
- package/src/utils/blockchain.ts +0 -43
- package/src/utils/e2e.ts +0 -55
- package/src/utils/flatten.ts +0 -17
- package/src/utils/formatters.ts +0 -36
- package/src/utils/html.utils.ts +0 -3
- package/src/utils/ownEvent.ts +0 -8
- package/src/utils/test.ts +0 -20
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
ComponentProps,
|
|
3
|
-
ForwardedRef,
|
|
4
|
-
forwardRef,
|
|
5
|
-
RefObject,
|
|
6
|
-
useCallback,
|
|
7
|
-
useEffect,
|
|
8
|
-
useImperativeHandle,
|
|
9
|
-
useMemo,
|
|
10
|
-
useRef,
|
|
11
|
-
useState,
|
|
12
|
-
} from "react";
|
|
13
|
-
|
|
14
|
-
const MAX_BALLS = 7;
|
|
15
|
-
const eachBallWidthEm = 1.2;
|
|
16
|
-
|
|
17
|
-
const CENTER_GUIDE_BALL = 1;
|
|
18
|
-
|
|
19
|
-
export enum PaginationIndicatorMode {
|
|
20
|
-
/** This will make the guide ball be kept on center */
|
|
21
|
-
CENTERED,
|
|
22
|
-
|
|
23
|
-
/** This will make the guide ball move, while the indicator balls keep in place */
|
|
24
|
-
START,
|
|
25
|
-
}
|
|
26
|
-
export function PaginationIndicatorView({
|
|
27
|
-
size,
|
|
28
|
-
page: currentPage,
|
|
29
|
-
pages: decimalPages,
|
|
30
|
-
className,
|
|
31
|
-
onClickPage,
|
|
32
|
-
mode = PaginationIndicatorMode.CENTERED,
|
|
33
|
-
infinite,
|
|
34
|
-
}: {
|
|
35
|
-
size: number;
|
|
36
|
-
page: number;
|
|
37
|
-
pages: number;
|
|
38
|
-
className?: string;
|
|
39
|
-
onClickPage?: (page: number) => void;
|
|
40
|
-
mode?: PaginationIndicatorMode;
|
|
41
|
-
infinite?: boolean;
|
|
42
|
-
}) {
|
|
43
|
-
const maxBalls = useMemo(() => (infinite ? 5 : MAX_BALLS), [infinite]);
|
|
44
|
-
const page = useMemo(() => {
|
|
45
|
-
const floor = Math.floor(decimalPages);
|
|
46
|
-
const modulus = decimalPages % floor;
|
|
47
|
-
|
|
48
|
-
if (currentPage > floor) {
|
|
49
|
-
const currentFloorModulus = currentPage % floor;
|
|
50
|
-
const equivalent = (currentFloorModulus * 100) / modulus;
|
|
51
|
-
|
|
52
|
-
return floor + equivalent / 100;
|
|
53
|
-
} else {
|
|
54
|
-
return currentPage;
|
|
55
|
-
}
|
|
56
|
-
}, [currentPage, decimalPages]);
|
|
57
|
-
const rand = useMemo(() => Math.random().toString(), []);
|
|
58
|
-
const pageIndex = page - 1;
|
|
59
|
-
const pages = useMemo(() => Math.ceil(decimalPages), [decimalPages]);
|
|
60
|
-
const numBalls = useMemo(() => {
|
|
61
|
-
const numBalls = pages >= maxBalls ? maxBalls : Math.ceil(pages);
|
|
62
|
-
|
|
63
|
-
return numBalls;
|
|
64
|
-
}, [pages]);
|
|
65
|
-
|
|
66
|
-
const indexForTheBallsCenter = useMemo(
|
|
67
|
-
() => (infinite ? numBalls - 5 : numBalls - 1) / 2,
|
|
68
|
-
[numBalls, infinite]
|
|
69
|
-
);
|
|
70
|
-
const balls = useMemo(() => {
|
|
71
|
-
const indexForLastPages = pages + 1 - indexForTheBallsCenter;
|
|
72
|
-
/**
|
|
73
|
-
* Is the page index (position of the center)
|
|
74
|
-
* after the first pages and
|
|
75
|
-
* before the last pages */
|
|
76
|
-
const isCenterPage =
|
|
77
|
-
numBalls >= maxBalls &&
|
|
78
|
-
pageIndex > indexForTheBallsCenter &&
|
|
79
|
-
pageIndex < indexForLastPages - 1;
|
|
80
|
-
let modulus =
|
|
81
|
-
pageIndex %
|
|
82
|
-
(1 + (indexForTheBallsCenter - Math.floor(indexForTheBallsCenter)));
|
|
83
|
-
const resetPageIndex = isCenterPage
|
|
84
|
-
? indexForTheBallsCenter + modulus
|
|
85
|
-
: pages < maxBalls
|
|
86
|
-
? pageIndex
|
|
87
|
-
: pageIndex >= indexForLastPages - 1
|
|
88
|
-
? numBalls - (pages - pageIndex)
|
|
89
|
-
: pageIndex;
|
|
90
|
-
const left = eachBallWidthEm * resetPageIndex;
|
|
91
|
-
const { pushBallsToRightBy, pushBallsToLeftBy, pushGuideToRightBy } =
|
|
92
|
-
mode === PaginationIndicatorMode.CENTERED
|
|
93
|
-
? {
|
|
94
|
-
pushBallsToRightBy: Math.min(pages, maxBalls) * eachBallWidthEm,
|
|
95
|
-
pushBallsToLeftBy: left,
|
|
96
|
-
pushGuideToRightBy: 0,
|
|
97
|
-
}
|
|
98
|
-
: {
|
|
99
|
-
pushBallsToRightBy: (eachBallWidthEm - 0.5) / 2,
|
|
100
|
-
pushBallsToLeftBy: 0,
|
|
101
|
-
pushGuideToRightBy: left,
|
|
102
|
-
};
|
|
103
|
-
let pushToLeft: number = 0;
|
|
104
|
-
return new Array(CENTER_GUIDE_BALL + numBalls)
|
|
105
|
-
.fill(undefined)
|
|
106
|
-
.map((_, i) => {
|
|
107
|
-
const isLastBall = i === numBalls - 1;
|
|
108
|
-
const isFirstBall = i === 0;
|
|
109
|
-
|
|
110
|
-
if (i === numBalls) {
|
|
111
|
-
const diameter = 0.45 * 2;
|
|
112
|
-
const padding = (eachBallWidthEm - diameter) / 2;
|
|
113
|
-
return (
|
|
114
|
-
<rect
|
|
115
|
-
fill="#fff"
|
|
116
|
-
width={`${diameter}em`}
|
|
117
|
-
height={`${diameter}em`}
|
|
118
|
-
x={`${
|
|
119
|
-
pushBallsToRightBy - padding + pushGuideToRightBy - pushToLeft
|
|
120
|
-
}em`}
|
|
121
|
-
y={`${padding}em`}
|
|
122
|
-
rx={`${diameter / 2}em`}
|
|
123
|
-
/>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const ballSize =
|
|
128
|
-
numBalls < maxBalls
|
|
129
|
-
? 0.5
|
|
130
|
-
: page <= indexForTheBallsCenter + 1 && isLastBall
|
|
131
|
-
? 0
|
|
132
|
-
: pageIndex >= indexForLastPages - 1 && isFirstBall
|
|
133
|
-
? 0
|
|
134
|
-
: isCenterPage
|
|
135
|
-
? isFirstBall
|
|
136
|
-
? 0.5 - modulus * 0.5
|
|
137
|
-
: isLastBall
|
|
138
|
-
? modulus * 0.5
|
|
139
|
-
: 0.5
|
|
140
|
-
: 0.5;
|
|
141
|
-
|
|
142
|
-
if (i === 0 && mode === PaginationIndicatorMode.START)
|
|
143
|
-
pushToLeft = (0.5 - ballSize) * 2.4;
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<rect
|
|
147
|
-
key={`guide-${i}`}
|
|
148
|
-
width={`${ballSize * 1.2}em`}
|
|
149
|
-
height={`${ballSize * 1.2}em`}
|
|
150
|
-
x={`${
|
|
151
|
-
pushBallsToRightBy +
|
|
152
|
-
i * eachBallWidthEm -
|
|
153
|
-
pushBallsToLeftBy -
|
|
154
|
-
pushToLeft
|
|
155
|
-
}em`}
|
|
156
|
-
y={`${(eachBallWidthEm - ballSize * 1.2) / 2}em`}
|
|
157
|
-
rx={`${(ballSize * 1.2) / 2}em`}
|
|
158
|
-
onClick={() => {
|
|
159
|
-
if (onClickPage) {
|
|
160
|
-
const pageClicked =
|
|
161
|
-
(!isCenterPage
|
|
162
|
-
? pageIndex >= indexForLastPages - 1
|
|
163
|
-
? Math.floor(page) - resetPageIndex - 1
|
|
164
|
-
: 0
|
|
165
|
-
: Math.floor(page) - (indexForTheBallsCenter + 1)) +
|
|
166
|
-
1 +
|
|
167
|
-
i;
|
|
168
|
-
onClickPage(Math.round(pageClicked));
|
|
169
|
-
}
|
|
170
|
-
}}
|
|
171
|
-
/>
|
|
172
|
-
);
|
|
173
|
-
});
|
|
174
|
-
}, [indexForTheBallsCenter, pageIndex, pages]);
|
|
175
|
-
const [guideBall, ...pageBalls] = balls.reverse();
|
|
176
|
-
let width = eachBallWidthEm * Math.min(pages, maxBalls) * 2;
|
|
177
|
-
if (mode === PaginationIndicatorMode.START) width /= 2;
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<svg
|
|
181
|
-
version="1.1"
|
|
182
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
183
|
-
className={className}
|
|
184
|
-
style={{
|
|
185
|
-
width: `${width}em`,
|
|
186
|
-
minWidth: `${width}em`,
|
|
187
|
-
height: "1.2em",
|
|
188
|
-
fontSize: `${size}px`,
|
|
189
|
-
}}
|
|
190
|
-
>
|
|
191
|
-
<filter id={`goo-${rand}`}>
|
|
192
|
-
<feGaussianBlur in="SourceGraphic" result="blur" stdDeviation="5" />
|
|
193
|
-
<feColorMatrix
|
|
194
|
-
in="blur"
|
|
195
|
-
mode="matrix"
|
|
196
|
-
values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7"
|
|
197
|
-
result="goo"
|
|
198
|
-
/>
|
|
199
|
-
<feBlend in2="goo" in="SourceGraphic" result="mix" />
|
|
200
|
-
</filter>
|
|
201
|
-
<mask id={`mask-${rand}`}>
|
|
202
|
-
<g filter={`url(#${`goo-${rand}`})`} fill="#fff">
|
|
203
|
-
{[pageBalls]}
|
|
204
|
-
{guideBall}
|
|
205
|
-
</g>
|
|
206
|
-
</mask>
|
|
207
|
-
<rect
|
|
208
|
-
x="0"
|
|
209
|
-
y="0"
|
|
210
|
-
mask={`url(#${`mask-${rand}`})`}
|
|
211
|
-
width="100%"
|
|
212
|
-
height="100%"
|
|
213
|
-
style={{ fill: "var(--digital-blue)" }}
|
|
214
|
-
></rect>
|
|
215
|
-
{onClickPage && (
|
|
216
|
-
<g opacity={0} style={{ cursor: "pointer" }}>
|
|
217
|
-
{pageBalls}
|
|
218
|
-
</g>
|
|
219
|
-
)}
|
|
220
|
-
</svg>
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export function AnimatedPaginationIndicator(
|
|
225
|
-
props: ComponentProps<typeof PaginationIndicatorView> & {
|
|
226
|
-
duration: number;
|
|
227
|
-
}
|
|
228
|
-
) {
|
|
229
|
-
const prevPage = useRef(props.page);
|
|
230
|
-
const [pageProgress, setPageProgress] = useState(props.page);
|
|
231
|
-
useEffect(() => {
|
|
232
|
-
const diff = props.page - prevPage.current;
|
|
233
|
-
const diffPerStep = diff / 60;
|
|
234
|
-
|
|
235
|
-
const interval = setInterval(() => {
|
|
236
|
-
setPageProgress((prev) => {
|
|
237
|
-
const next = prev + diffPerStep;
|
|
238
|
-
if (diff < 0) {
|
|
239
|
-
if (next <= props.page) {
|
|
240
|
-
clearInterval(interval);
|
|
241
|
-
return props.page;
|
|
242
|
-
}
|
|
243
|
-
} else {
|
|
244
|
-
if (next >= props.page) {
|
|
245
|
-
clearInterval(interval);
|
|
246
|
-
return props.page;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
return Number(next.toFixed(2));
|
|
250
|
-
});
|
|
251
|
-
}, props.duration / 60);
|
|
252
|
-
|
|
253
|
-
return () => {
|
|
254
|
-
prevPage.current = props.page;
|
|
255
|
-
clearInterval(interval);
|
|
256
|
-
};
|
|
257
|
-
}, [props.page]);
|
|
258
|
-
|
|
259
|
-
return <PaginationIndicatorView {...props} page={pageProgress} />;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function _PaginationIndicator(
|
|
263
|
-
{
|
|
264
|
-
scrollableRef,
|
|
265
|
-
estimatedWidth,
|
|
266
|
-
size,
|
|
267
|
-
className = "",
|
|
268
|
-
onClickPage,
|
|
269
|
-
mode,
|
|
270
|
-
infinite,
|
|
271
|
-
}: {
|
|
272
|
-
scrollableRef: RefObject<HTMLDivElement>;
|
|
273
|
-
estimatedWidth?: number;
|
|
274
|
-
size: number;
|
|
275
|
-
className?: string;
|
|
276
|
-
onClickPage?: (page: number) => void;
|
|
277
|
-
} & Pick<ComponentProps<typeof PaginationIndicatorView>, "mode" | "infinite">,
|
|
278
|
-
ref: ForwardedRef<{
|
|
279
|
-
refreshPages: () => void;
|
|
280
|
-
}>
|
|
281
|
-
) {
|
|
282
|
-
const [currentPage, setCurrentPage] = useState(1);
|
|
283
|
-
|
|
284
|
-
const [defs, setDefs] =
|
|
285
|
-
useState<{
|
|
286
|
-
pages: number;
|
|
287
|
-
}>();
|
|
288
|
-
|
|
289
|
-
const refreshPages = useCallback(() => {
|
|
290
|
-
if (!scrollableRef.current) return;
|
|
291
|
-
const maxWidth =
|
|
292
|
-
estimatedWidth === undefined
|
|
293
|
-
? scrollableRef.current!.scrollWidth
|
|
294
|
-
: estimatedWidth;
|
|
295
|
-
|
|
296
|
-
const pages = maxWidth / scrollableRef.current!.clientWidth;
|
|
297
|
-
if (pages > 1)
|
|
298
|
-
setDefs({
|
|
299
|
-
pages: infinite ? pages + 2 : pages,
|
|
300
|
-
});
|
|
301
|
-
}, [estimatedWidth, infinite]);
|
|
302
|
-
|
|
303
|
-
useEffect(() => refreshPages(), [refreshPages]);
|
|
304
|
-
|
|
305
|
-
const updatePageIndicators = useCallback(
|
|
306
|
-
(target: HTMLDivElement, pages: number) => {
|
|
307
|
-
if (!scrollableRef.current) return;
|
|
308
|
-
const eachPageWidth = scrollableRef.current!.clientWidth;
|
|
309
|
-
const page = 1 + target.scrollLeft / eachPageWidth;
|
|
310
|
-
const lastPageProgress = Math.floor(pages) + 1;
|
|
311
|
-
const maximumProgress = pages + 1;
|
|
312
|
-
|
|
313
|
-
const diffToMax = maximumProgress - lastPageProgress;
|
|
314
|
-
const currentProgressOnDiff = page - lastPageProgress;
|
|
315
|
-
|
|
316
|
-
if (page > lastPageProgress) {
|
|
317
|
-
const p = lastPageProgress + currentProgressOnDiff / diffToMax;
|
|
318
|
-
setCurrentPage(p);
|
|
319
|
-
} else setCurrentPage(page);
|
|
320
|
-
},
|
|
321
|
-
[]
|
|
322
|
-
);
|
|
323
|
-
|
|
324
|
-
useImperativeHandle(
|
|
325
|
-
ref,
|
|
326
|
-
() => ({
|
|
327
|
-
refreshPages,
|
|
328
|
-
}),
|
|
329
|
-
[]
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
useEffect(() => {
|
|
333
|
-
if (!defs) return;
|
|
334
|
-
const el = scrollableRef.current!;
|
|
335
|
-
const onScroll = (e: Event) =>
|
|
336
|
-
updatePageIndicators(e.currentTarget as HTMLDivElement, defs.pages);
|
|
337
|
-
updatePageIndicators(el, defs.pages);
|
|
338
|
-
el.addEventListener("scroll", onScroll, {
|
|
339
|
-
passive: true,
|
|
340
|
-
});
|
|
341
|
-
return () => {
|
|
342
|
-
el.removeEventListener("scroll", onScroll);
|
|
343
|
-
};
|
|
344
|
-
}, [defs]);
|
|
345
|
-
|
|
346
|
-
const pages = useMemo(() => (defs ? defs.pages : undefined), [defs]);
|
|
347
|
-
|
|
348
|
-
return !pages ? null : (
|
|
349
|
-
<PaginationIndicatorView
|
|
350
|
-
pages={pages}
|
|
351
|
-
page={currentPage}
|
|
352
|
-
size={size}
|
|
353
|
-
className={className}
|
|
354
|
-
onClickPage={onClickPage}
|
|
355
|
-
mode={mode}
|
|
356
|
-
infinite={infinite}
|
|
357
|
-
/>
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* A cool component to indicate how many pages are
|
|
363
|
-
**/
|
|
364
|
-
const PaginationIndicator = forwardRef(_PaginationIndicator);
|
|
365
|
-
export default PaginationIndicator;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
@import "../../assets/styles/index.scss";
|
|
2
|
-
|
|
3
|
-
.parallax {
|
|
4
|
-
display: flex;
|
|
5
|
-
position: relative;
|
|
6
|
-
transition: transform $fast;
|
|
7
|
-
overflow: hidden;
|
|
8
|
-
user-select: none;
|
|
9
|
-
transform: translate3d(0, 0, 0);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.reflection {
|
|
13
|
-
transform: translateX(-50%) translateY(-50%);
|
|
14
|
-
width: 40%;
|
|
15
|
-
pointer-events: none;
|
|
16
|
-
&::after {
|
|
17
|
-
background: radial-gradient(#fff2, #fff2 5%, #aaa0 50%);
|
|
18
|
-
background-size: 100% 100%;
|
|
19
|
-
content: "";
|
|
20
|
-
display: block;
|
|
21
|
-
padding-bottom: 100%;
|
|
22
|
-
border-radius: 50%;
|
|
23
|
-
background-repeat: no-repeat;
|
|
24
|
-
}
|
|
25
|
-
position: absolute;
|
|
26
|
-
left: -50%;
|
|
27
|
-
top: -50%;
|
|
28
|
-
}
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
DetailedHTMLProps,
|
|
3
|
-
ForwardedRef,
|
|
4
|
-
forwardRef,
|
|
5
|
-
HTMLAttributes,
|
|
6
|
-
MutableRefObject,
|
|
7
|
-
PropsWithChildren,
|
|
8
|
-
useEffect,
|
|
9
|
-
useRef,
|
|
10
|
-
} from "react";
|
|
11
|
-
import { throttle } from "lodash";
|
|
12
|
-
import Styles from "./Parallax.module.scss";
|
|
13
|
-
import {
|
|
14
|
-
flattenMatrix,
|
|
15
|
-
generateMatrixFromOperations,
|
|
16
|
-
invertMatrix,
|
|
17
|
-
} from "./math/helpers";
|
|
18
|
-
import { calculateDistanceRelativeToBounds, givenTheRelativePositionHowMuchToRotate } from "../../hooks/ui/useTilt";
|
|
19
|
-
|
|
20
|
-
const MAXIMUM_PARALLAX = {
|
|
21
|
-
x: 20,
|
|
22
|
-
y: 20,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type Props = PropsWithChildren<{
|
|
26
|
-
className?: string;
|
|
27
|
-
active: boolean;
|
|
28
|
-
onClick?: (e: any) => void;
|
|
29
|
-
reflection?: boolean;
|
|
30
|
-
maxParallax?: {
|
|
31
|
-
x: number;
|
|
32
|
-
y: number;
|
|
33
|
-
};
|
|
34
|
-
}> &
|
|
35
|
-
DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
36
|
-
|
|
37
|
-
function _Parallax(
|
|
38
|
-
{
|
|
39
|
-
children,
|
|
40
|
-
className = "",
|
|
41
|
-
active,
|
|
42
|
-
onClick,
|
|
43
|
-
reflection,
|
|
44
|
-
maxParallax = MAXIMUM_PARALLAX,
|
|
45
|
-
...props
|
|
46
|
-
}: Props,
|
|
47
|
-
ref: ForwardedRef<HTMLDivElement>
|
|
48
|
-
) {
|
|
49
|
-
const parallaxableRef = useRef<HTMLDivElement>(null);
|
|
50
|
-
const reflectionRef = useRef<HTMLDivElement>(null);
|
|
51
|
-
const multiplierRef = useRef<number>(1);
|
|
52
|
-
const initialPositionRef = useRef<string>(undefined);
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (ref)
|
|
55
|
-
(ref as MutableRefObject<HTMLDivElement>).current =
|
|
56
|
-
parallaxableRef.current!;
|
|
57
|
-
const el = parallaxableRef.current!;
|
|
58
|
-
if (active && !initialPositionRef.current) {
|
|
59
|
-
initialPositionRef.current = getComputedStyle(el).transform;
|
|
60
|
-
if (initialPositionRef.current === "none")
|
|
61
|
-
initialPositionRef.current = "";
|
|
62
|
-
el.style.transform = `${initialPositionRef.current} rotateX(0deg) rotateY(0deg) translateZ(0px)`;
|
|
63
|
-
}
|
|
64
|
-
// eslint-disable-next-line
|
|
65
|
-
}, [active]);
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
const el = parallaxableRef.current!;
|
|
69
|
-
if (active) {
|
|
70
|
-
const updatePositions = (relativeToX: number, relativeToY: number) => {
|
|
71
|
-
const rect = el.getBoundingClientRect();
|
|
72
|
-
const {
|
|
73
|
-
width: [x0, xW],
|
|
74
|
-
height: [y0, yH],
|
|
75
|
-
} = {
|
|
76
|
-
width: [rect.left, el.clientWidth],
|
|
77
|
-
height: [rect.top, el.clientHeight],
|
|
78
|
-
};
|
|
79
|
-
const distanceOffRight = calculateDistanceRelativeToBounds(
|
|
80
|
-
relativeToX,
|
|
81
|
-
x0,
|
|
82
|
-
xW,
|
|
83
|
-
true
|
|
84
|
-
);
|
|
85
|
-
const distanceOffBottom = calculateDistanceRelativeToBounds(
|
|
86
|
-
relativeToY,
|
|
87
|
-
y0,
|
|
88
|
-
yH,
|
|
89
|
-
true
|
|
90
|
-
);
|
|
91
|
-
const howMuchToRotateY =
|
|
92
|
-
givenTheRelativePositionHowMuchToRotate(
|
|
93
|
-
distanceOffRight,
|
|
94
|
-
maxParallax.y
|
|
95
|
-
) * multiplierRef.current;
|
|
96
|
-
const howMuchToRotateX =
|
|
97
|
-
givenTheRelativePositionHowMuchToRotate(
|
|
98
|
-
distanceOffBottom,
|
|
99
|
-
maxParallax.x
|
|
100
|
-
) * multiplierRef.current;
|
|
101
|
-
|
|
102
|
-
const howMuchToOpacify = Math.abs(
|
|
103
|
-
Math.abs(distanceOffBottom - 0.5) / 0.5
|
|
104
|
-
);
|
|
105
|
-
const howMuchToOpacifyHorizontal = Math.max(
|
|
106
|
-
Math.abs(Math.abs(distanceOffRight - 0.5) / 0.5),
|
|
107
|
-
Math.abs(Math.abs(distanceOffBottom - 0.5) / 0.5)
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
el.style.transform = `${initialPositionRef.current
|
|
111
|
-
} rotateY(${howMuchToRotateY}deg) rotateX(${-howMuchToRotateX}deg) translateZ(${multiplierRef.current === 1 ? 0 : -30
|
|
112
|
-
}px)`;
|
|
113
|
-
|
|
114
|
-
if (reflectionRef.current) {
|
|
115
|
-
reflectionRef.current.style.left = `${(1 - distanceOffRight) * 100}%`;
|
|
116
|
-
reflectionRef.current.style.top = `${(1 - distanceOffBottom) * 100}%`;
|
|
117
|
-
reflectionRef.current.style.opacity = `${Math.min(
|
|
118
|
-
howMuchToOpacify,
|
|
119
|
-
howMuchToOpacifyHorizontal
|
|
120
|
-
)}`;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const handler = throttle(({ x, y }: MouseEvent) => {
|
|
124
|
-
updatePositions(x, y);
|
|
125
|
-
}, 1000 / 30);
|
|
126
|
-
const touchHandler = throttle(({ touches }: TouchEvent) => {
|
|
127
|
-
const { pageX, pageY } = touches[0];
|
|
128
|
-
updatePositions(pageX, pageY);
|
|
129
|
-
}, 1000 / 30);
|
|
130
|
-
const mouseDownHandler = () => {
|
|
131
|
-
multiplierRef.current = 1.5;
|
|
132
|
-
};
|
|
133
|
-
const mouseUpHandler = () => {
|
|
134
|
-
multiplierRef.current = 1;
|
|
135
|
-
};
|
|
136
|
-
window.addEventListener("mousemove", handler);
|
|
137
|
-
window.addEventListener("touchmove", touchHandler);
|
|
138
|
-
let _inverseMatrix: number[] | undefined;
|
|
139
|
-
const _limits: {
|
|
140
|
-
[k in "beta" | "gamma"]?: [number, number];
|
|
141
|
-
} = {
|
|
142
|
-
beta: undefined,
|
|
143
|
-
gamma: undefined,
|
|
144
|
-
};
|
|
145
|
-
const orientationListener: (e: DeviceOrientationEvent) => void = ({
|
|
146
|
-
beta,
|
|
147
|
-
gamma,
|
|
148
|
-
}) => {
|
|
149
|
-
beta = beta! * 0.5;
|
|
150
|
-
gamma = gamma! * 0.5;
|
|
151
|
-
if (!_inverseMatrix) {
|
|
152
|
-
window.removeEventListener("mousemove", handler);
|
|
153
|
-
window.removeEventListener("touchmove", touchHandler);
|
|
154
|
-
const offset = 12.5;
|
|
155
|
-
_limits.beta = [beta! - offset, beta! + offset];
|
|
156
|
-
_limits.gamma = [gamma! - offset, gamma! + offset];
|
|
157
|
-
}
|
|
158
|
-
const _beta = Math.min(
|
|
159
|
-
_limits.beta![1],
|
|
160
|
-
Math.max(_limits.beta![0], beta!)
|
|
161
|
-
);
|
|
162
|
-
const _gamma = Math.min(
|
|
163
|
-
_limits.gamma![1],
|
|
164
|
-
Math.max(_limits.gamma![0], gamma!)
|
|
165
|
-
);
|
|
166
|
-
if (!_inverseMatrix) {
|
|
167
|
-
_inverseMatrix = flattenMatrix(
|
|
168
|
-
invertMatrix(
|
|
169
|
-
generateMatrixFromOperations(
|
|
170
|
-
{
|
|
171
|
-
type: "rotateY",
|
|
172
|
-
angle: _gamma!,
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
type: "rotateX",
|
|
176
|
-
angle: -_beta!,
|
|
177
|
-
}
|
|
178
|
-
)
|
|
179
|
-
)
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
el.style.transform = `matrix3d(${_inverseMatrix.join(
|
|
183
|
-
","
|
|
184
|
-
)}) rotateX(${-_beta!}deg) rotateY(${_gamma}deg)`;
|
|
185
|
-
};
|
|
186
|
-
window.addEventListener("deviceorientation", orientationListener);
|
|
187
|
-
window.addEventListener("touchend", () => {
|
|
188
|
-
_inverseMatrix = undefined;
|
|
189
|
-
});
|
|
190
|
-
el.addEventListener("touchstart", mouseDownHandler);
|
|
191
|
-
el.addEventListener("touchend", mouseUpHandler);
|
|
192
|
-
el.addEventListener("mousedown", mouseDownHandler);
|
|
193
|
-
el.addEventListener("mouseup", mouseUpHandler);
|
|
194
|
-
|
|
195
|
-
return () => {
|
|
196
|
-
window.removeEventListener("deviceorientation", orientationListener);
|
|
197
|
-
window.removeEventListener("mousemove", handler);
|
|
198
|
-
window.removeEventListener("touchmove", touchHandler);
|
|
199
|
-
el.removeEventListener("mousedown", mouseDownHandler);
|
|
200
|
-
el.removeEventListener("mouseup", mouseUpHandler);
|
|
201
|
-
el.removeEventListener("touchstart", mouseDownHandler);
|
|
202
|
-
el.removeEventListener("touchend", mouseUpHandler);
|
|
203
|
-
// el.style.transform = initialPositionRef.current!;
|
|
204
|
-
el.style.transform = `rotateX(0deg) rotateY(0deg) translateZ(0px)`;
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
}, [active]);
|
|
208
|
-
return (
|
|
209
|
-
<div
|
|
210
|
-
onClick={onClick}
|
|
211
|
-
ref={parallaxableRef}
|
|
212
|
-
className={`${Styles.parallax} ${className}`}
|
|
213
|
-
{...props}
|
|
214
|
-
>
|
|
215
|
-
{children}
|
|
216
|
-
{reflection && <div ref={reflectionRef} className={Styles.reflection} />}
|
|
217
|
-
</div>
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* It holds a children and animates a tilt effect relative to mouse position
|
|
223
|
-
**/
|
|
224
|
-
const Parallax = forwardRef(_Parallax);
|
|
225
|
-
export default Parallax;
|