@onepercentio/one-ui 0.20.4 → 0.21.0
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/.babelrc +6 -0
- package/.prod.babelrc +8 -2
- package/dist/assets/styles/variables.scss +1 -0
- package/dist/components/AdaptiveButton/AdaptiveButton.js +2 -2
- package/dist/components/AdaptiveContainer/AdaptiveContainer.js +28 -26
- package/dist/components/AdaptiveContainer/AdaptiveContainer.module.scss +3 -1
- package/dist/components/AdaptiveDialog/AdaptiveDialog.js +9 -9
- package/dist/components/AdaptiveSidebar/AdaptiveSidebar.js +14 -14
- package/dist/components/AnchoredTooltip/AnchoredTooltip.js +30 -30
- package/dist/components/AnimatedEntrance/AnimatedEntrance.d.ts +1 -1
- package/dist/components/AnimatedEntrance/AnimatedEntrance.js +34 -45
- package/dist/components/AsyncWrapper/AsyncWrapper.js +2 -2
- package/dist/components/Avatar/Avatar.js +4 -4
- package/dist/components/BucketFill/BucketFill.js +9 -9
- package/dist/components/Button/Button.js +4 -4
- package/dist/components/Card/Card.js +1 -1
- package/dist/components/Chart/Chart.view.js +34 -34
- package/dist/components/CheckBox/CheckBox.js +3 -3
- package/dist/components/Collapsable/Collapsable.js +18 -18
- package/dist/components/Countdown/Countdown.js +16 -16
- package/dist/components/Divider/Divider.js +1 -1
- package/dist/components/EmailInput/EmailInput.d.ts +1 -1
- package/dist/components/EmailInput/EmailInput.js +4 -4
- package/dist/components/FadeIn/FadeIn.js +9 -9
- package/dist/components/FileInput/FileInput.js +6 -6
- package/dist/components/FileInput/View/BigFactory/BigFactory.js +1 -1
- package/dist/components/FileInput/View/Compact/Compact.js +6 -6
- package/dist/components/FlowController/FlowController.js +4 -4
- package/dist/components/Form/Form.js +17 -28
- package/dist/components/Freeze/Freeze.js +1 -1
- package/dist/components/HSForms/HSForms.js +9 -11
- package/dist/components/Header/Header.js +7 -7
- package/dist/components/HeaderCloseBtn/HeaderCloseBtn.js +1 -1
- package/dist/components/InfinityScroll/InfinityScroll.js +25 -25
- package/dist/components/Input/Input.js +13 -13
- package/dist/components/InstantCounter/InstantCounter.js +9 -9
- package/dist/components/LavaLamp/LavaLamp.data.js +25 -25
- package/dist/components/LavaLamp/LavaLamp.js +7 -7
- package/dist/components/LavaLamp/v2/LavaLamp.js +29 -45
- package/dist/components/LinkToId/LinkToId.js +7 -7
- package/dist/components/Loader/Loader.js +2 -2
- package/dist/components/LoaderDotsIndicator/LoaderDotsIndicator.js +6 -6
- package/dist/components/LoopableVideo/LoopableVideo.js +4 -4
- package/dist/components/MainGrid/MainGrid.js +2 -2
- package/dist/components/MutableHamburgerButton/MutableHamburgerButton.js +2 -2
- package/dist/components/Notification/Notification.js +1 -1
- package/dist/components/OrderableList/OrderableList.js +113 -138
- package/dist/components/PaginationIndicator/PaginationIndicator.js +50 -50
- package/dist/components/Parallax/Parallax.js +39 -39
- package/dist/components/Parallax/math/helpers.js +18 -19
- package/dist/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/components/PasswordInput/PasswordInput.js +10 -10
- package/dist/components/PingPongText/PingPongText.js +15 -15
- package/dist/components/PixelatedScan/PixelatedScan.js +19 -19
- package/dist/components/Portal/Portal.js +10 -10
- package/dist/components/ProgressBar/ProgressBar.js +6 -6
- package/dist/components/ProgressTexts/ProgressTexts.js +3 -3
- package/dist/components/Radio/Radio.js +3 -3
- package/dist/components/SectionContainer/SectionContainer.js +1 -1
- package/dist/components/Select/Select.js +13 -13
- package/dist/components/Select/Select.module.scss +8 -5
- package/dist/components/Skeleton/Skeleton.js +1 -1
- package/dist/components/Spacing/Spacing.js +1 -1
- package/dist/components/StaticScroller/StaticScroller.js +12 -12
- package/dist/components/Switch/Switch.js +2 -2
- package/dist/components/Table/Table.js +11 -11
- package/dist/components/Tabs/Tabs.d.ts +6 -1
- package/dist/components/Tabs/Tabs.js +28 -9
- package/dist/components/Tabs/Tabs.module.scss +20 -2
- package/dist/components/Text/Text.js +5 -5
- package/dist/components/Transition/MasksFactory/DiagonalReveal.js +5 -5
- package/dist/components/Transition/MasksFactory/DiagonalSquareToBalls.js +17 -17
- package/dist/components/Transition/MasksFactory/PhysicsSquares.js +13 -13
- package/dist/components/Transition/MasksFactory/SquareToBalls.js +9 -9
- package/dist/components/Transition/MasksFactory/utils.js +8 -8
- package/dist/components/Transition/Transition.js +49 -49
- package/dist/components/UncontrolledTransition/UncontrolledTransition.js +7 -7
- package/dist/components/WalletConnectionWrapper/WalletConnectionWrapper.js +44 -82
- package/dist/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.js +6 -6
- package/dist/context/AsyncProcess.js +19 -42
- package/dist/context/CustomBrowserRouter.js +6 -6
- package/dist/context/OneUIProvider.js +15 -15
- package/dist/hooks/logs/useDependencyChangeDetection.js +2 -5
- package/dist/hooks/persistence/useLocalStorage.js +7 -7
- package/dist/hooks/shims/ObjectWatchShim.js +1 -15
- package/dist/hooks/ui/useAdaptiveImage.js +6 -6
- package/dist/hooks/ui/useBreakpoint.js +5 -5
- package/dist/hooks/ui/useCustomScrollbar.js +2 -2
- package/dist/hooks/ui/useMouseHover.js +4 -4
- package/dist/hooks/ui/usePaginationControls.js +34 -34
- package/dist/hooks/ui/useSnapToViewport.js +3 -3
- package/dist/hooks/ui/useTilt.js +38 -38
- package/dist/hooks/ui/useZoomable.js +20 -20
- package/dist/hooks/useAsyncControl.js +21 -38
- package/dist/hooks/useContainedRepositioning.js +22 -22
- package/dist/hooks/useCustomHistory.js +2 -2
- package/dist/hooks/useElementFit.js +6 -6
- package/dist/hooks/useFirestoreWatch.js +26 -39
- package/dist/hooks/useForm.js +8 -8
- package/dist/hooks/useFreeze.js +1 -1
- package/dist/hooks/useHero.d.ts +1 -0
- package/dist/hooks/useHero.js +132 -91
- package/dist/hooks/useHero.module.scss +7 -0
- package/dist/hooks/useIntersection.js +3 -3
- package/dist/hooks/useMergeRefs.js +3 -7
- package/dist/hooks/useObserve.js +5 -5
- package/dist/hooks/usePagination.js +39 -59
- package/dist/hooks/usePooledOperation.js +8 -22
- package/dist/hooks/usePooling.js +17 -33
- package/dist/hooks/useRebound.js +5 -5
- package/dist/hooks/useShortIntl.js +13 -13
- package/dist/hooks/utility/useEvents.js +5 -5
- package/dist/hooks/utility/useModule.js +3 -3
- package/dist/hooks/utility/useQuery.js +1 -1
- package/dist/models/DebugLogger.js +2 -2
- package/dist/models/GenericContract.js +1 -1
- package/dist/storybookUtils/index.js +1 -1
- package/dist/types.d.ts +11 -4
- package/dist/utility.d.js +3 -3
- package/dist/utils/blockchain.js +29 -102
- package/dist/utils/flatten.js +3 -3
- package/dist/utils/html.utils.js +1 -1
- package/package.json +2 -1
- package/src/types.ts +155 -41
package/dist/hooks/useHero.js
CHANGED
|
@@ -15,61 +15,96 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
15
15
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
16
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
17
17
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
19
18
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
20
19
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0)
|
|
20
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
22
21
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
22
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
24
23
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
25
24
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
26
25
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
27
26
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
28
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
29
|
-
|
|
27
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
28
|
+
const ID = function ID(id) {
|
|
30
29
|
return "".concat(id, "-hero");
|
|
31
30
|
};
|
|
32
|
-
|
|
31
|
+
const viewport = window.visualViewport;
|
|
32
|
+
const DATA_TAG_HERO_COMPONENT = "data-hero-component";
|
|
33
|
+
function triggerDynamicComponents(clone, componentsThatWillAppear) {
|
|
34
|
+
const idsThatWillAppear = componentsThatWillAppear.map(function (a) {
|
|
35
|
+
return a.getAttribute(DATA_TAG_HERO_COMPONENT);
|
|
36
|
+
});
|
|
37
|
+
const preexistingComponents = Array.from(clone.querySelectorAll("[".concat(DATA_TAG_HERO_COMPONENT, "]")));
|
|
38
|
+
const removedElements = preexistingComponents.filter(function (el) {
|
|
39
|
+
return !idsThatWillAppear.includes(el.getAttribute(DATA_TAG_HERO_COMPONENT));
|
|
40
|
+
});
|
|
41
|
+
for (let elementThatIsBeingRemoved of removedElements) {
|
|
42
|
+
elementThatIsBeingRemoved.style.height = "".concat(elementThatIsBeingRemoved.clientHeight, "px");
|
|
43
|
+
}
|
|
44
|
+
setTimeout(function () {
|
|
45
|
+
for (let elementThatIsBeingRemoved of removedElements) {
|
|
46
|
+
elementThatIsBeingRemoved.style.height = "0px";
|
|
47
|
+
elementThatIsBeingRemoved.style.opacity = "0";
|
|
48
|
+
}
|
|
49
|
+
}, 0);
|
|
50
|
+
for (let componentThatWillAppear of componentsThatWillAppear) {
|
|
51
|
+
const alreadyInjectedElement = !!clone.querySelector("[".concat(DATA_TAG_HERO_COMPONENT, "=\"").concat(componentThatWillAppear.getAttribute(DATA_TAG_HERO_COMPONENT), "\"]"));
|
|
52
|
+
if (!alreadyInjectedElement) {
|
|
53
|
+
const targetElementClone = componentThatWillAppear.cloneNode(true);
|
|
54
|
+
targetElementClone.style.height = "0px";
|
|
55
|
+
const shouldBeInsrtedAtIndex = Array.from(componentThatWillAppear.parentElement.children).indexOf(componentThatWillAppear);
|
|
56
|
+
const remainingIndexes = Array.from(clone.children).map(function (el, i) {
|
|
57
|
+
return removedElements.includes(el) ? undefined : i;
|
|
58
|
+
}).filter(function (e) {
|
|
59
|
+
return e !== undefined;
|
|
60
|
+
});
|
|
61
|
+
if (shouldBeInsrtedAtIndex === remainingIndexes.length) clone.append(targetElementClone);else clone.insertBefore(targetElementClone, clone.childNodes.item(remainingIndexes[shouldBeInsrtedAtIndex]));
|
|
62
|
+
setTimeout(function () {
|
|
63
|
+
targetElementClone.style.height = "".concat(componentThatWillAppear.clientHeight, "px");
|
|
64
|
+
}, 0);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
33
68
|
|
|
34
69
|
/**
|
|
35
70
|
* This hook implements the logic for a hero animation between 2 elements
|
|
36
71
|
*/
|
|
37
72
|
function useHero(id) {
|
|
38
|
-
|
|
73
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
39
74
|
propsToTransition: []
|
|
40
75
|
};
|
|
41
|
-
|
|
42
|
-
|
|
76
|
+
let events = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
77
|
+
const _options$propsToTrans = options.propsToTransition,
|
|
43
78
|
propsToTransition = _options$propsToTrans === void 0 ? [] : _options$propsToTrans,
|
|
44
79
|
dataPreffix = options["data-preffix"],
|
|
45
80
|
repeatable = options.repeatable;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
81
|
+
const _dataPreffix = dataPreffix ? "-".concat(dataPreffix) : "";
|
|
82
|
+
const dataProperty = "data".concat(_dataPreffix, "-hero");
|
|
83
|
+
const heroRef = (0, _react.useRef)(null);
|
|
49
84
|
(0, _react.useLayoutEffect)(function () {
|
|
50
85
|
heroRef.current.setAttribute(dataProperty, id);
|
|
51
86
|
}, [id]);
|
|
52
|
-
|
|
53
|
-
|
|
87
|
+
const getHerosOnScreen = (0, _react.useCallback)(function () {
|
|
88
|
+
const otherElements = Array.from(document.querySelectorAll("[".concat(dataProperty, "=\"").concat(id, "\"]"))).filter(function (el) {
|
|
54
89
|
return el !== heroRef.current;
|
|
55
90
|
});
|
|
56
91
|
return otherElements;
|
|
57
92
|
}, [id]);
|
|
58
93
|
function triggerHeroAnimation() {
|
|
59
|
-
|
|
60
|
-
|
|
94
|
+
const allPropsToTransition = ["width", "height", "top", "left"].concat(_toConsumableArray(propsToTransition));
|
|
95
|
+
const shouldHeroFn = events.onHeroDetect || function () {
|
|
61
96
|
return true;
|
|
62
97
|
};
|
|
63
|
-
|
|
98
|
+
const otherElements = getHerosOnScreen().filter(function (el) {
|
|
64
99
|
return shouldHeroFn(el, heroRef.current);
|
|
65
100
|
});
|
|
66
|
-
|
|
101
|
+
const currentElCoordinates = heroRef.current.getBoundingClientRect();
|
|
67
102
|
if (process.env.NODE_ENV === "development" && otherElements.length > 2) console.warn("There are too many elements to transition to, I will transition to the first I find", otherElements);
|
|
68
|
-
|
|
103
|
+
const otherElement = otherElements.find(function (el) {
|
|
69
104
|
return el !== heroRef.current;
|
|
70
105
|
});
|
|
71
106
|
if (otherElement) {
|
|
72
|
-
|
|
107
|
+
let willTheHeroMove = function willTheHeroMove(origin, target) {
|
|
73
108
|
return !(origin.top === target.top && origin.left === target.left && origin.width === target.width && origin.height === target.height);
|
|
74
109
|
};
|
|
75
110
|
/**
|
|
@@ -77,22 +112,22 @@ function useHero(id) {
|
|
|
77
112
|
* @param el
|
|
78
113
|
* @returns Returns if it will move
|
|
79
114
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
115
|
+
let setCloneToCoordinatesOf = function setCloneToCoordinatesOf(el) {
|
|
116
|
+
const coordinates = el.getBoundingClientRect();
|
|
117
|
+
const currentCoordinates = clone.getBoundingClientRect();
|
|
118
|
+
const willMove = willTheHeroMove(coordinates, currentCoordinates);
|
|
119
|
+
clone.style.position = "fixed";
|
|
120
|
+
clone.style.top = "".concat(coordinates.top, "px");
|
|
121
|
+
clone.style.left = "".concat(coordinates.left, "px");
|
|
122
|
+
clone.style.width = "".concat(coordinates.width, "px");
|
|
123
|
+
clone.style.height = "".concat(coordinates.height, "px");
|
|
89
124
|
return willMove;
|
|
90
125
|
};
|
|
91
|
-
|
|
126
|
+
const _ref = events.onBeforeTransition ? events.onBeforeTransition(otherElement, heroRef.current) : [viewport, viewport],
|
|
92
127
|
_ref2 = _slicedToArray(_ref, 2),
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
128
|
+
originContainer = _ref2[0],
|
|
129
|
+
targetContainer = _ref2[1];
|
|
130
|
+
const shouldSkip = isElementOutsideContainer(targetContainer, currentElCoordinates) || isElementOutsideContainer(originContainer, otherElement.getBoundingClientRect()) ? (events.onHeroSkip || function () {
|
|
96
131
|
return true;
|
|
97
132
|
})(otherElement, heroRef.current) : false;
|
|
98
133
|
if (shouldSkip) {
|
|
@@ -100,14 +135,14 @@ function useHero(id) {
|
|
|
100
135
|
(_events$onHeroSkipped = events.onHeroSkipped) === null || _events$onHeroSkipped === void 0 ? void 0 : _events$onHeroSkipped.call(events);
|
|
101
136
|
return;
|
|
102
137
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (events.onHeroCloned && !oldClone) events.onHeroCloned(
|
|
138
|
+
const oldClone = document.querySelector("[".concat(dataProperty, "-clone=\"").concat(ID(id), "\"]"));
|
|
139
|
+
const clone = oldClone || otherElement.cloneNode(true);
|
|
140
|
+
if (events.onHeroCloned && !oldClone) events.onHeroCloned(clone);
|
|
106
141
|
|
|
107
142
|
// Clean up thos properties that can cause confusion since it's a clone
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
143
|
+
clone.style.visibility = "";
|
|
144
|
+
clone.removeAttribute(dataProperty);
|
|
145
|
+
clone.setAttribute("".concat(dataProperty, "-clone"), ID(id));
|
|
111
146
|
|
|
112
147
|
/**
|
|
113
148
|
* If it's repeatable, we should keep the flag that indicates the hero existance
|
|
@@ -115,72 +150,66 @@ function useHero(id) {
|
|
|
115
150
|
if (!repeatable)
|
|
116
151
|
// Since a transition is now triggering from the old element, he cannot be considered for other transitions
|
|
117
152
|
otherElement.removeAttribute(dataProperty);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
153
|
+
const coordinates = otherElement.getBoundingClientRect();
|
|
154
|
+
const currentCoordinates = heroRef.current.getBoundingClientRect();
|
|
155
|
+
const itWontMove = !willTheHeroMove(coordinates, currentCoordinates);
|
|
121
156
|
if (itWontMove) return;
|
|
122
157
|
if (!oldClone) {
|
|
123
158
|
/** Set the clone over the starting element */
|
|
124
159
|
setCloneToCoordinatesOf(otherElement);
|
|
125
|
-
document.body.appendChild(
|
|
160
|
+
document.body.appendChild(clone);
|
|
126
161
|
}
|
|
127
162
|
heroRef.current.style.visibility = "hidden";
|
|
128
163
|
otherElement.style.visibility = "hidden";
|
|
129
|
-
|
|
164
|
+
clone.style.transition = "".concat(allPropsToTransition.map(function (prop) {
|
|
130
165
|
return "".concat(prop, " var(--animation--speed-fast, 250ms) ease-out");
|
|
131
166
|
}).join(", "));
|
|
132
167
|
setTimeout(function () {
|
|
133
|
-
|
|
134
|
-
|
|
168
|
+
const el = heroRef.current;
|
|
169
|
+
const cleanup = function cleanup() {
|
|
135
170
|
if (events.onHeroEnd) events.onHeroEnd();
|
|
136
|
-
_clone.remove();
|
|
137
171
|
if (el) {
|
|
138
172
|
if (repeatable) el.setAttribute(dataProperty, id);
|
|
139
173
|
el.style.visibility = "";
|
|
140
174
|
}
|
|
175
|
+
setTimeout(function () {
|
|
176
|
+
clone.remove();
|
|
177
|
+
}, 0);
|
|
141
178
|
};
|
|
142
|
-
if (events.onHeroStart)
|
|
179
|
+
if (events.onHeroStart) {
|
|
180
|
+
events.onHeroStart(clone, otherElement, heroRef.current);
|
|
181
|
+
}
|
|
182
|
+
triggerDynamicComponents(clone, Array.from(heroRef.current.querySelectorAll("[".concat(DATA_TAG_HERO_COMPONENT, "]"))));
|
|
143
183
|
if (!el) {
|
|
144
184
|
cleanup();
|
|
145
185
|
return;
|
|
146
186
|
}
|
|
147
187
|
/** Set the clone over the new position */
|
|
148
|
-
|
|
188
|
+
const willMove = setCloneToCoordinatesOf(el);
|
|
149
189
|
if (!willMove) cleanup();else {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
_clone.style[propToTransition] = window.getComputedStyle(el)[propToTransition];
|
|
156
|
-
}
|
|
157
|
-
} catch (err) {
|
|
158
|
-
_iterator.e(err);
|
|
159
|
-
} finally {
|
|
160
|
-
_iterator.f();
|
|
161
|
-
}
|
|
162
|
-
var initialOffset;
|
|
163
|
-
var s = function s(_ref3) {
|
|
164
|
-
var target = _ref3.target;
|
|
165
|
-
var d = target;
|
|
190
|
+
for (let propToTransition of propsToTransition) clone.style[propToTransition] = window.getComputedStyle(el)[propToTransition];
|
|
191
|
+
let initialOffset;
|
|
192
|
+
const s = function s(_ref3) {
|
|
193
|
+
let target = _ref3.target;
|
|
194
|
+
const d = target;
|
|
166
195
|
if (d.contains(el)) {
|
|
167
|
-
if (initialOffset === undefined) initialOffset = d.scrollTop;else
|
|
196
|
+
if (initialOffset === undefined) initialOffset = d.scrollTop;else clone.style.marginTop = "".concat(-(d.scrollTop - initialOffset), "px");
|
|
168
197
|
}
|
|
169
198
|
};
|
|
170
|
-
|
|
171
|
-
|
|
199
|
+
const transitionEndCb = (0, _ownEvent.default)(function (_ref4) {
|
|
200
|
+
let target = _ref4.target,
|
|
172
201
|
currentTarget = _ref4.currentTarget;
|
|
173
202
|
if (target === currentTarget) cleanup();
|
|
174
203
|
document.removeEventListener("scroll", s, true);
|
|
175
204
|
});
|
|
176
205
|
document.addEventListener("scroll", s, true);
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
206
|
+
clone.addEventListener("transitionend", transitionEndCb);
|
|
207
|
+
clone.addEventListener("transitionstart", function () {
|
|
208
|
+
const onCancelCb = (0, _ownEvent.default)(function (e) {
|
|
209
|
+
clone.removeEventListener("transitionend", transitionEndCb);
|
|
210
|
+
clone.removeEventListener("transitioncancel", onCancelCb);
|
|
182
211
|
});
|
|
183
|
-
|
|
212
|
+
clone.addEventListener("transitioncancel", onCancelCb);
|
|
184
213
|
});
|
|
185
214
|
}
|
|
186
215
|
}, 0);
|
|
@@ -192,52 +221,64 @@ function useHero(id) {
|
|
|
192
221
|
return {
|
|
193
222
|
heroRef: heroRef,
|
|
194
223
|
getHerosOnScreen: getHerosOnScreen,
|
|
195
|
-
trigger: triggerHeroAnimation
|
|
224
|
+
trigger: triggerHeroAnimation,
|
|
225
|
+
heroComponentRef: function heroComponentRef(componentId) {
|
|
226
|
+
return function (elRef) {
|
|
227
|
+
if (elRef) {
|
|
228
|
+
elRef.setAttribute(DATA_TAG_HERO_COMPONENT, componentId);
|
|
229
|
+
elRef.classList.add(_useHeroModule.default.component);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}
|
|
196
233
|
};
|
|
197
234
|
}
|
|
198
235
|
function isElementOutsideViewport(coordinates) {
|
|
199
|
-
|
|
200
|
-
|
|
236
|
+
const elementOverflowsViewport = coordinates.left >= viewport.width || coordinates.top >= viewport.height;
|
|
237
|
+
const elementUnderflowsViewport = coordinates.left <= -coordinates.width || coordinates.top <= -coordinates.height;
|
|
201
238
|
return elementOverflowsViewport || elementUnderflowsViewport;
|
|
202
239
|
}
|
|
203
240
|
function isElementOutsideContainer(container, coordinates) {
|
|
204
241
|
if (container instanceof VisualViewport) {
|
|
205
242
|
return isElementOutsideViewport(coordinates);
|
|
206
243
|
} else {
|
|
207
|
-
|
|
208
|
-
|
|
244
|
+
const containerBounds = container.getBoundingClientRect();
|
|
245
|
+
const isContainerOutsideViewport = isElementOutsideViewport(containerBounds);
|
|
209
246
|
if (isContainerOutsideViewport) return true;
|
|
210
|
-
|
|
211
|
-
|
|
247
|
+
const elementOverflowsViewport = coordinates.left >= containerBounds.left + containerBounds.width || coordinates.top >= containerBounds.top + containerBounds.height;
|
|
248
|
+
const elementUnderflowsViewport = containerBounds.left - coordinates.left >= coordinates.width || containerBounds.top - coordinates.top >= coordinates.height;
|
|
212
249
|
return elementUnderflowsViewport || elementOverflowsViewport;
|
|
213
250
|
}
|
|
214
251
|
}
|
|
215
252
|
function centerPoint(rect) {
|
|
216
253
|
return [rect.left + rect.width / 2, rect.top + rect.height / 2];
|
|
217
254
|
}
|
|
218
|
-
|
|
255
|
+
const angle = function angle(pointA, pointB) {
|
|
219
256
|
return Number((Math.atan2(pointA[1] - pointB[1], pointA[0] - pointB[0]) * (179.08 / Math.PI)).toFixed(5));
|
|
220
257
|
};
|
|
221
|
-
|
|
258
|
+
const TRANSITION_FACTORY = {
|
|
222
259
|
ACCELERATION: function ACCELERATION(events) {
|
|
223
260
|
return _objectSpread(_objectSpread({}, events), {}, {
|
|
224
261
|
onHeroStart: function onHeroStart(clone, origin, target) {
|
|
225
262
|
if (events !== null && events !== void 0 && events.onHeroStart) events.onHeroStart(clone, origin, target);
|
|
226
263
|
clone.classList.add(_useHeroModule.default.acceleration);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
264
|
+
const centerPointOrigin = centerPoint(origin.getBoundingClientRect());
|
|
265
|
+
const centerPointDestination = centerPoint(target.getBoundingClientRect());
|
|
266
|
+
const angleBetweenElements = angle(centerPointOrigin, centerPointDestination);
|
|
267
|
+
const vectorX = Math.sin(angleBetweenElements);
|
|
268
|
+
const vectorY = Math.cos(angleBetweenElements);
|
|
269
|
+
const rotateY = (10 * vectorY).toFixed(0);
|
|
270
|
+
const originX = (vectorY + 1) * 50;
|
|
271
|
+
const rotateX = -(10 * vectorX).toFixed(0);
|
|
272
|
+
const originY = (vectorX + 1) * 50;
|
|
236
273
|
clone.style.setProperty("--stage-1", "rotateY(".concat(rotateY, "deg) rotateX(").concat(-rotateX, "deg)"));
|
|
237
274
|
clone.style.setProperty("--stage-2", "rotateY(".concat(-rotateY * 0.3, "deg) rotateX(").concat(rotateX * 0.3, "deg)"));
|
|
238
275
|
clone.style.setProperty("--origin-1", "".concat(originX, "% ").concat(originY, "%"));
|
|
239
276
|
clone.style.setProperty("--origin-2", "".concat(100 - originX, "% ").concat(100 - originY, "%"));
|
|
240
277
|
document.body.style.perspective = "100vw";
|
|
278
|
+
},
|
|
279
|
+
onHeroEnd: function onHeroEnd() {
|
|
280
|
+
if (events !== null && events !== void 0 && events.onHeroEnd) events.onHeroEnd();
|
|
281
|
+
document.body.style.perspective = "";
|
|
241
282
|
}
|
|
242
283
|
});
|
|
243
284
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import "../assets/styles/index.scss";
|
|
2
|
+
|
|
1
3
|
$timing: cubic-bezier(0.5, -0.45, 0.44, 1.37);
|
|
2
4
|
// $timing: cubic-bezier(0.73, -0.49, 0.16, 1.4);
|
|
3
5
|
|
|
@@ -31,3 +33,8 @@ $timing: cubic-bezier(0.5, -0.45, 0.44, 1.37);
|
|
|
31
33
|
transform: rotateY(0deg);
|
|
32
34
|
}
|
|
33
35
|
}
|
|
36
|
+
|
|
37
|
+
.component {
|
|
38
|
+
transition: height $fast linear, opacity $fast linear;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
}
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = useIntersection;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
function useIntersection() {
|
|
9
|
-
|
|
9
|
+
const _useRef = (0, _react.useRef)([]),
|
|
10
10
|
targetMap = _useRef.current;
|
|
11
|
-
|
|
11
|
+
const _useRef2 = (0, _react.useRef)("IntersectionObserver" in window ? new IntersectionObserver(function (els) {
|
|
12
12
|
els.forEach(function (e, i) {
|
|
13
|
-
|
|
13
|
+
const result = targetMap.find(function (el) {
|
|
14
14
|
return el[0] === e.target;
|
|
15
15
|
});
|
|
16
16
|
if (result && e.isIntersecting) {
|
|
@@ -14,10 +14,7 @@ function useMergeRefs(mainRef) {
|
|
|
14
14
|
otherRefs[_key - 1] = arguments[_key];
|
|
15
15
|
}
|
|
16
16
|
(0, _react.useLayoutEffect)(function () {
|
|
17
|
-
for (
|
|
18
|
-
var _ref = _otherRefs[_i];
|
|
19
|
-
_ref.current = mainRef.current;
|
|
20
|
-
}
|
|
17
|
+
for (let ref of otherRefs) ref.current = mainRef.current;
|
|
21
18
|
}, []);
|
|
22
19
|
return mainRef;
|
|
23
20
|
}
|
|
@@ -30,9 +27,8 @@ function useMergeRefsFunc(mainRef) {
|
|
|
30
27
|
otherRefs[_key2 - 1] = arguments[_key2];
|
|
31
28
|
}
|
|
32
29
|
return function (providedRef) {
|
|
33
|
-
if (providedRef) for (
|
|
34
|
-
|
|
35
|
-
if (typeof _ref2 === "function") _ref2(providedRef);else _ref2.current = providedRef;
|
|
30
|
+
if (providedRef) for (let ref of [mainRef].concat(otherRefs)) {
|
|
31
|
+
if (typeof ref === "function") ref(providedRef);else ref.current = providedRef;
|
|
36
32
|
}
|
|
37
33
|
};
|
|
38
34
|
}
|
package/dist/hooks/useObserve.js
CHANGED
|
@@ -9,17 +9,17 @@ require("./shims/ObjectWatchShim.js");
|
|
|
9
9
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
10
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
11
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
13
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0)
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
14
14
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
15
|
function useObserve(toObserve, keysToObserve) {
|
|
16
|
-
|
|
16
|
+
const _useState = (0, _react.useState)(0),
|
|
17
17
|
_useState2 = _slicedToArray(_useState, 2),
|
|
18
18
|
_ = _useState2[0],
|
|
19
19
|
ss = _useState2[1];
|
|
20
20
|
(0, _react.useLayoutEffect)(function () {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const arr = Array.isArray(toObserve) ? toObserve : [toObserve];
|
|
22
|
+
const unwatchers = arr.map(function (object) {
|
|
23
23
|
return object.watch(keysToObserve, function () {
|
|
24
24
|
ss(function (p) {
|
|
25
25
|
return p + 1;
|