@pinnacle0/web-ui 0.4.32 → 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,7 +1,7 @@
1
1
  import React from "react";
2
+ import "../../internal/polyfill/ResizeObserver";
2
3
  import "./index.less";
3
4
  export interface Props {
4
- height: number;
5
5
  children: React.ReactNode;
6
6
  className?: string;
7
7
  styles?: React.CSSProperties;
@@ -11,4 +11,4 @@ export interface State {
11
11
  hasShadowChildren: boolean;
12
12
  paused: boolean;
13
13
  }
14
- export declare const VerticalMarquee: ({ className: extraClassName, speed, height, styles, children }: Props) => JSX.Element;
14
+ export declare const VerticalMarquee: ({ className: extraClassName, speed, styles, children }: Props) => JSX.Element;
@@ -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,24 +16,42 @@ 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 extraClassName = _a.className, speed = _a.speed, height = _a.height, styles = _a.styles, children = _a.children;
34
- var _b = __read(React.useState(0), 2), contentHeight = _b[0], setContentHeight = _b[1];
23
+ var extraClassName = _a.className, speed = _a.speed, styles = _a.styles, children = _a.children;
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];
26
+ var containerRef = React.useRef(null);
35
27
  var animationSpeed = contentHeight / (speed || 30);
36
- var marqueeInnerRef = React.useCallback(function (node) {
37
- if (!node) {
28
+ var getContainerHeight = React.useCallback(function () {
29
+ if (!containerRef.current)
38
30
  return;
39
- }
40
- setContentHeight(node === null || node === void 0 ? void 0 : node.clientHeight);
31
+ setContainerHeight(containerRef.current.clientHeight);
41
32
  }, []);
33
+ var marqueeInnerRef = function (node) {
34
+ if (!node)
35
+ return;
36
+ setContentHeight(node === null || node === void 0 ? void 0 : node.clientHeight);
37
+ };
42
38
  var marqueeInnerAnimationStyle = React.useMemo(function () { return ({
43
39
  animation: "marquee ".concat(animationSpeed, "s linear infinite"),
44
40
  transform: "translate(0, calc(-100% + ".concat(contentHeight / 2, "px))"),
45
41
  }); }, [animationSpeed, contentHeight]);
46
- var pageSize = contentHeight / height;
47
- return (React.createElement("div", { className: classNames("g-marquee", extraClassName), style: __assign(__assign({}, styles), { height: height }) },
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 },
48
55
  React.createElement("div", { ref: marqueeInnerRef, className: "inner", style: pageSize > 1 ? marqueeInnerAnimationStyle : undefined },
49
56
  children,
50
57
  children)));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/VerticalMarquee/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,E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10
  overflow: hidden;
9
11
 
10
12
  .inner:hover {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinnacle0/web-ui",
3
- "version": "0.4.32",
3
+ "version": "0.4.34",
4
4
  "author": "Pinnacle",
5
5
  "license": "MIT",
6
6
  "sideEffects": [