@pinnacle0/web-ui 0.4.33 → 0.4.34
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.
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
var __read = (this && this.__read) || function (o, n) {
|
|
13
2
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
3
|
if (!m) return o;
|
|
@@ -27,29 +16,44 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
27
16
|
};
|
|
28
17
|
import React from "react";
|
|
29
18
|
import { classNames } from "../../util/ClassNames";
|
|
30
|
-
import "./index.less";
|
|
31
19
|
import { ReactUtil } from "../../util/ReactUtil";
|
|
20
|
+
import "../../internal/polyfill/ResizeObserver";
|
|
21
|
+
import "./index.less";
|
|
32
22
|
export var VerticalMarquee = ReactUtil.memo("VerticalMarquee", function (_a) {
|
|
33
|
-
var _b, _c;
|
|
34
23
|
var extraClassName = _a.className, speed = _a.speed, styles = _a.styles, children = _a.children;
|
|
35
|
-
var
|
|
36
|
-
var
|
|
24
|
+
var _b = __read(React.useState(0), 2), containerHeight = _b[0], setContainerHeight = _b[1];
|
|
25
|
+
var _c = __read(React.useState(0), 2), contentHeight = _c[0], setContentHeight = _c[1];
|
|
37
26
|
var containerRef = React.useRef(null);
|
|
38
|
-
var
|
|
39
|
-
|
|
27
|
+
var animationSpeed = contentHeight / (speed || 30);
|
|
28
|
+
var getContainerHeight = React.useCallback(function () {
|
|
29
|
+
if (!containerRef.current)
|
|
40
30
|
return;
|
|
41
|
-
|
|
42
|
-
setContentHeight(node === null || node === void 0 ? void 0 : node.clientHeight);
|
|
31
|
+
setContainerHeight(containerRef.current.clientHeight);
|
|
43
32
|
}, []);
|
|
33
|
+
var marqueeInnerRef = function (node) {
|
|
34
|
+
if (!node)
|
|
35
|
+
return;
|
|
36
|
+
setContentHeight(node === null || node === void 0 ? void 0 : node.clientHeight);
|
|
37
|
+
};
|
|
44
38
|
var marqueeInnerAnimationStyle = React.useMemo(function () { return ({
|
|
45
39
|
animation: "marquee ".concat(animationSpeed, "s linear infinite"),
|
|
46
40
|
transform: "translate(0, calc(-100% + ".concat(contentHeight / 2, "px))"),
|
|
47
41
|
}); }, [animationSpeed, contentHeight]);
|
|
48
|
-
var pageSize = contentHeight /
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
var pageSize = contentHeight / containerHeight;
|
|
43
|
+
React.useEffect(function () {
|
|
44
|
+
if (containerRef.current) {
|
|
45
|
+
getContainerHeight();
|
|
46
|
+
var observer = new ResizeObserver(function (entries) {
|
|
47
|
+
var target = entries.find(function (entry) { return entry.target === containerRef.current; });
|
|
48
|
+
target && getContainerHeight();
|
|
49
|
+
});
|
|
50
|
+
observer.observe(containerRef.current);
|
|
51
|
+
return observer.disconnect;
|
|
52
|
+
}
|
|
53
|
+
}, [getContainerHeight]);
|
|
54
|
+
return (React.createElement("div", { className: classNames("g-marquee", extraClassName), ref: containerRef, style: styles },
|
|
55
|
+
React.createElement("div", { ref: marqueeInnerRef, className: "inner", style: pageSize > 1 ? marqueeInnerAnimationStyle : undefined },
|
|
56
|
+
children,
|
|
57
|
+
children)));
|
|
54
58
|
});
|
|
55
59
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/VerticalMarquee/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","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;
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.inner:hover {
|
|
14
|
-
animation-play-state: paused !important;
|
|
15
|
-
}
|
|
12
|
+
.inner:hover {
|
|
13
|
+
animation-play-state: paused !important;
|
|
16
14
|
}
|
|
17
15
|
}
|