deepsea-components 5.0.7 → 5.1.1
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/cjs/components/InfiniteScroll.d.ts +31 -0
- package/dist/cjs/components/InfiniteScroll.js +133 -0
- package/dist/cjs/components/InfiniteScroll.js.map +7 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/components/AutoFit.d.ts.map +1 -0
- package/dist/esm/components/AutoScroll.d.ts.map +1 -0
- package/dist/esm/components/AutoSizeTextarea.d.ts.map +1 -0
- package/dist/esm/components/CircleText.d.ts.map +1 -0
- package/dist/esm/components/Flow.d.ts.map +1 -0
- package/dist/esm/components/HlsPlayer.d.ts.map +1 -0
- package/dist/esm/components/InfiniteScroll.d.ts +31 -0
- package/dist/esm/components/InfiniteScroll.d.ts.map +1 -0
- package/dist/esm/components/InfiniteScroll.js +100 -0
- package/dist/esm/components/InfiniteScroll.js.map +1 -0
- package/dist/esm/components/InputFile.d.ts.map +1 -0
- package/dist/esm/components/LoopSwiper.d.ts.map +1 -0
- package/dist/esm/components/Ring.d.ts.map +1 -0
- package/dist/esm/components/Scroll.d.ts.map +1 -0
- package/dist/esm/components/SectionRing.d.ts.map +1 -0
- package/dist/esm/components/Skeleton.d.ts.map +1 -0
- package/dist/esm/components/TransitionBox.d.ts.map +1 -0
- package/dist/esm/components/TransitionNum.d.ts.map +1 -0
- package/dist/esm/components/Trapezium.d.ts.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/InfiniteScroll.tsx +135 -0
- package/src/index.tsx +1 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ComponentProps, CSSProperties } from "react";
|
|
2
|
+
export type InfiniteScrollProps = ComponentProps<"div"> & {
|
|
3
|
+
/**
|
|
4
|
+
* 滚动的方向
|
|
5
|
+
* @default "vertical"
|
|
6
|
+
*/
|
|
7
|
+
direction?: "vertical" | "horizontal";
|
|
8
|
+
/** 渲染 children 的容器的类名 */
|
|
9
|
+
containerClassName?: string;
|
|
10
|
+
/** 渲染 children 的容器的样式 */
|
|
11
|
+
containerStyle?: CSSProperties;
|
|
12
|
+
/**
|
|
13
|
+
* 两个 children 容器之间的间距
|
|
14
|
+
* @default 0
|
|
15
|
+
*/
|
|
16
|
+
gap?: number;
|
|
17
|
+
/** 一个周期的时间,单位:毫秒 */
|
|
18
|
+
duration: number;
|
|
19
|
+
/** 是否将 gap 的距离也加入 overflow 的计算 */
|
|
20
|
+
withGap?: boolean;
|
|
21
|
+
/** 尺寸刚好相同时,是否视为溢出 */
|
|
22
|
+
withEqual?: boolean;
|
|
23
|
+
/** 鼠标移入时,是否停止动画 */
|
|
24
|
+
pauseOnHover?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 无限滚动的组件
|
|
28
|
+
* 子元素会内置的容器中被渲染两次,首尾相连,形成无限滚动的效果
|
|
29
|
+
* 但是,如果内部检测到并没有溢出,那么不会渲染两次,并且没有动画
|
|
30
|
+
*/
|
|
31
|
+
export declare const InfiniteScroll: import("react").ForwardRefExoticComponent<Omit<InfiniteScrollProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/components/InfiniteScroll.tsx
|
|
20
|
+
var InfiniteScroll_exports = {};
|
|
21
|
+
__export(InfiniteScroll_exports, {
|
|
22
|
+
InfiniteScroll: () => InfiniteScroll
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(InfiniteScroll_exports);
|
|
25
|
+
var import_css = require("@emotion/css");
|
|
26
|
+
var import_ahooks = require("ahooks");
|
|
27
|
+
var import_deepsea_tools = require("deepsea-tools");
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var InfiniteScroll = (0, import_react.forwardRef)((props, ref) => {
|
|
30
|
+
const { className, direction = "vertical", children, containerClassName, containerStyle, gap = 0, duration, withGap, withEqual, pauseOnHover, onMouseEnter, onMouseLeave, ...rest } = props;
|
|
31
|
+
const wrapper = (0, import_react.useRef)(null);
|
|
32
|
+
const wrapperSize = (0, import_ahooks.useSize)(wrapper);
|
|
33
|
+
const ele = (0, import_react.useRef)(null);
|
|
34
|
+
(0, import_react.useImperativeHandle)(ref, () => wrapper.current, [wrapper.current]);
|
|
35
|
+
const container = (0, import_react.useRef)(null);
|
|
36
|
+
const containerSize = (0, import_ahooks.useSize)(container);
|
|
37
|
+
function bigger(containerSize2, wrapperSize2) {
|
|
38
|
+
return withEqual ? containerSize2 + (withGap ? gap : 0) >= wrapperSize2 : containerSize2 + (withGap ? gap : 0) > wrapperSize2;
|
|
39
|
+
}
|
|
40
|
+
const overflow = wrapperSize && containerSize ? direction === "vertical" ? bigger(containerSize.height, wrapperSize.height) : bigger(containerSize.width, wrapperSize.width) : false;
|
|
41
|
+
const animation = (0, import_react.useRef)(void 0);
|
|
42
|
+
(0, import_react.useEffect)(() => {
|
|
43
|
+
if (!wrapperSize || !containerSize || !overflow)
|
|
44
|
+
return;
|
|
45
|
+
animation.current = ele.current?.animate(
|
|
46
|
+
{
|
|
47
|
+
transform: direction === "vertical" ? [`translateY(0)`, `translateY(-${containerSize.height + gap}px)`] : [`translateX(0)`, `translateX(-${containerSize.width + gap}px)`]
|
|
48
|
+
},
|
|
49
|
+
{ duration, iterations: Infinity }
|
|
50
|
+
);
|
|
51
|
+
return () => animation.current?.cancel();
|
|
52
|
+
}, [wrapperSize, containerSize, overflow, direction, duration]);
|
|
53
|
+
function enter(e) {
|
|
54
|
+
if (pauseOnHover)
|
|
55
|
+
animation.current?.pause();
|
|
56
|
+
onMouseEnter?.(e);
|
|
57
|
+
}
|
|
58
|
+
function leave(e) {
|
|
59
|
+
if (pauseOnHover)
|
|
60
|
+
animation.current?.play();
|
|
61
|
+
onMouseLeave?.(e);
|
|
62
|
+
}
|
|
63
|
+
(0, import_react.useEffect)(() => {
|
|
64
|
+
if (!pauseOnHover)
|
|
65
|
+
animation.current?.play();
|
|
66
|
+
}, [animation.current, pauseOnHover]);
|
|
67
|
+
return /* @__PURE__ */ React.createElement(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
ref: wrapper,
|
|
71
|
+
className: (0, import_deepsea_tools.clsx)(
|
|
72
|
+
import_css.css`
|
|
73
|
+
position: relative;
|
|
74
|
+
overflow: hidden;
|
|
75
|
+
`,
|
|
76
|
+
className
|
|
77
|
+
),
|
|
78
|
+
onMouseEnter: enter,
|
|
79
|
+
onMouseLeave: leave,
|
|
80
|
+
...rest
|
|
81
|
+
},
|
|
82
|
+
/* @__PURE__ */ React.createElement(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
ref: ele,
|
|
86
|
+
style: {
|
|
87
|
+
position: "absolute",
|
|
88
|
+
width: direction === "vertical" ? "100%" : containerSize && (overflow ? containerSize.width * 2 + gap : containerSize.width),
|
|
89
|
+
height: direction === "horizontal" ? "100%" : containerSize && (overflow ? containerSize.height * 2 + gap : containerSize.width)
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
/* @__PURE__ */ React.createElement(
|
|
93
|
+
"div",
|
|
94
|
+
{
|
|
95
|
+
ref: container,
|
|
96
|
+
className: (0, import_deepsea_tools.clsx)(
|
|
97
|
+
import_css.css`
|
|
98
|
+
position: absolute;
|
|
99
|
+
left: 0;
|
|
100
|
+
top: 0;
|
|
101
|
+
${direction === "vertical" ? "width: 100%;" : "height: 100%;"}
|
|
102
|
+
`,
|
|
103
|
+
containerClassName
|
|
104
|
+
),
|
|
105
|
+
style: containerStyle
|
|
106
|
+
},
|
|
107
|
+
children
|
|
108
|
+
),
|
|
109
|
+
overflow && /* @__PURE__ */ React.createElement(
|
|
110
|
+
"div",
|
|
111
|
+
{
|
|
112
|
+
ref: container,
|
|
113
|
+
className: (0, import_deepsea_tools.clsx)(
|
|
114
|
+
import_css.css`
|
|
115
|
+
position: absolute;
|
|
116
|
+
right: 0;
|
|
117
|
+
bottom: 0;
|
|
118
|
+
${direction === "vertical" ? "width: 100%;" : "height: 100%;"}
|
|
119
|
+
`,
|
|
120
|
+
containerClassName
|
|
121
|
+
),
|
|
122
|
+
style: containerStyle
|
|
123
|
+
},
|
|
124
|
+
children
|
|
125
|
+
)
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
});
|
|
129
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
+
0 && (module.exports = {
|
|
131
|
+
InfiniteScroll
|
|
132
|
+
});
|
|
133
|
+
//# sourceMappingURL=InfiniteScroll.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/InfiniteScroll.tsx"],
|
|
4
|
+
"sourcesContent": ["import { css } from \"@emotion/css\"\r\nimport { useSize } from \"ahooks\"\r\nimport { clsx } from \"deepsea-tools\"\r\nimport { ComponentProps, CSSProperties, forwardRef, MouseEvent as ReactMouseEvent, useEffect, useImperativeHandle, useRef } from \"react\"\r\n\r\nexport type InfiniteScrollProps = ComponentProps<\"div\"> & {\r\n /**\r\n * 滚动的方向\r\n * @default \"vertical\"\r\n */\r\n direction?: \"vertical\" | \"horizontal\"\r\n /** 渲染 children 的容器的类名 */\r\n containerClassName?: string\r\n /** 渲染 children 的容器的样式 */\r\n containerStyle?: CSSProperties\r\n /**\r\n * 两个 children 容器之间的间距\r\n * @default 0\r\n */\r\n gap?: number\r\n /** 一个周期的时间,单位:毫秒 */\r\n duration: number\r\n /** 是否将 gap 的距离也加入 overflow 的计算 */\r\n withGap?: boolean\r\n /** 尺寸刚好相同时,是否视为溢出 */\r\n withEqual?: boolean\r\n /** 鼠标移入时,是否停止动画 */\r\n pauseOnHover?: boolean\r\n}\r\n\r\n/**\r\n * 无限滚动的组件\r\n * 子元素会内置的容器中被渲染两次,首尾相连,形成无限滚动的效果\r\n * 但是,如果内部检测到并没有溢出,那么不会渲染两次,并且没有动画\r\n */\r\nexport const InfiniteScroll = forwardRef<HTMLDivElement, InfiniteScrollProps>((props, ref) => {\r\n const { className, direction = \"vertical\", children, containerClassName, containerStyle, gap = 0, duration, withGap, withEqual, pauseOnHover, onMouseEnter, onMouseLeave, ...rest } = props\r\n\r\n const wrapper = useRef<HTMLDivElement>(null)\r\n const wrapperSize = useSize(wrapper)\r\n\r\n const ele = useRef<HTMLDivElement>(null)\r\n\r\n useImperativeHandle(ref, () => wrapper.current as HTMLDivElement, [wrapper.current])\r\n\r\n const container = useRef<HTMLDivElement>(null)\r\n const containerSize = useSize(container)\r\n\r\n function bigger(containerSize: number, wrapperSize: number) {\r\n return withEqual ? containerSize + (withGap ? gap : 0) >= wrapperSize : containerSize + (withGap ? gap : 0) > wrapperSize\r\n }\r\n\r\n const overflow = wrapperSize && containerSize ? (direction === \"vertical\" ? bigger(containerSize.height, wrapperSize.height) : bigger(containerSize.width, wrapperSize.width)) : false\r\n\r\n const animation = useRef<Animation | undefined>(undefined)\r\n\r\n useEffect(() => {\r\n if (!wrapperSize || !containerSize || !overflow) return\r\n animation.current = ele.current?.animate(\r\n {\r\n transform: direction === \"vertical\" ? [`translateY(0)`, `translateY(-${containerSize.height + gap}px)`] : [`translateX(0)`, `translateX(-${containerSize.width + gap}px)`]\r\n },\r\n { duration, iterations: Infinity }\r\n )\r\n return () => animation.current?.cancel()\r\n }, [wrapperSize, containerSize, overflow, direction, duration])\r\n\r\n function enter(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {\r\n if (pauseOnHover) animation.current?.pause()\r\n onMouseEnter?.(e)\r\n }\r\n\r\n function leave(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {\r\n if (pauseOnHover) animation.current?.play()\r\n onMouseLeave?.(e)\r\n }\r\n\r\n useEffect(() => {\r\n if (!pauseOnHover) animation.current?.play()\r\n }, [animation.current, pauseOnHover])\r\n\r\n return (\r\n <div\r\n ref={wrapper}\r\n className={clsx(\r\n css`\r\n position: relative;\r\n overflow: hidden;\r\n `,\r\n className\r\n )}\r\n onMouseEnter={enter}\r\n onMouseLeave={leave}\r\n {...rest}>\r\n <div\r\n ref={ele}\r\n style={{\r\n position: \"absolute\",\r\n width: direction === \"vertical\" ? \"100%\" : containerSize && (overflow ? containerSize.width * 2 + gap : containerSize.width),\r\n height: direction === \"horizontal\" ? \"100%\" : containerSize && (overflow ? containerSize.height * 2 + gap : containerSize.width)\r\n }}>\r\n <div\r\n ref={container}\r\n className={clsx(\r\n css`\r\n position: absolute;\r\n left: 0;\r\n top: 0;\r\n ${direction === \"vertical\" ? \"width: 100%;\" : \"height: 100%;\"}\r\n `,\r\n containerClassName\r\n )}\r\n style={containerStyle}>\r\n {children}\r\n </div>\r\n {overflow && (\r\n <div\r\n ref={container}\r\n className={clsx(\r\n css`\r\n position: absolute;\r\n right: 0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A,YAElD;AAAA,UACJ;AAAA,UACA,OAAO;AAAA;AAAA,QACN;AAAA,MACL;AAAA,IAER;AAAA,EACJ;AAER,CAAC;",
|
|
6
|
+
"names": ["containerSize", "wrapperSize"]
|
|
7
|
+
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./components/AutoSizeTextarea";
|
|
|
4
4
|
export * from "./components/CircleText";
|
|
5
5
|
export * from "./components/Flow";
|
|
6
6
|
export * from "./components/HlsPlayer";
|
|
7
|
+
export * from "./components/InfiniteScroll";
|
|
7
8
|
export * from "./components/InputFile";
|
|
8
9
|
export * from "./components/LoopSwiper";
|
|
9
10
|
export * from "./components/Ring";
|
package/dist/cjs/index.js
CHANGED
|
@@ -22,6 +22,7 @@ __reExport(src_exports, require("./components/AutoSizeTextarea"), module.exports
|
|
|
22
22
|
__reExport(src_exports, require("./components/CircleText"), module.exports);
|
|
23
23
|
__reExport(src_exports, require("./components/Flow"), module.exports);
|
|
24
24
|
__reExport(src_exports, require("./components/HlsPlayer"), module.exports);
|
|
25
|
+
__reExport(src_exports, require("./components/InfiniteScroll"), module.exports);
|
|
25
26
|
__reExport(src_exports, require("./components/InputFile"), module.exports);
|
|
26
27
|
__reExport(src_exports, require("./components/LoopSwiper"), module.exports);
|
|
27
28
|
__reExport(src_exports, require("./components/Ring"), module.exports);
|
|
@@ -39,6 +40,7 @@ __reExport(src_exports, require("./components/Trapezium"), module.exports);
|
|
|
39
40
|
...require("./components/CircleText"),
|
|
40
41
|
...require("./components/Flow"),
|
|
41
42
|
...require("./components/HlsPlayer"),
|
|
43
|
+
...require("./components/InfiniteScroll"),
|
|
42
44
|
...require("./components/InputFile"),
|
|
43
45
|
...require("./components/LoopSwiper"),
|
|
44
46
|
...require("./components/Ring"),
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["export * from \"./components/AutoFit\"\r\nexport * from \"./components/AutoScroll\"\r\nexport * from \"./components/AutoSizeTextarea\"\r\nexport * from \"./components/CircleText\"\r\nexport * from \"./components/Flow\"\r\nexport * from \"./components/HlsPlayer\"\r\nexport * from \"./components/InputFile\"\r\nexport * from \"./components/LoopSwiper\"\r\nexport * from \"./components/Ring\"\r\nexport * from \"./components/Scroll\"\r\nexport * from \"./components/SectionRing\"\r\nexport * from \"./components/Skeleton\"\r\nexport * from \"./components/TransitionBox\"\r\nexport * from \"./components/TransitionNum\"\r\nexport * from \"./components/Trapezium\"\r\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,iCAAd;AACA,wBAAc,oCADd;AAEA,wBAAc,0CAFd;AAGA,wBAAc,oCAHd;AAIA,wBAAc,8BAJd;AAKA,wBAAc,mCALd;AAMA,wBAAc,
|
|
4
|
+
"sourcesContent": ["export * from \"./components/AutoFit\"\r\nexport * from \"./components/AutoScroll\"\r\nexport * from \"./components/AutoSizeTextarea\"\r\nexport * from \"./components/CircleText\"\r\nexport * from \"./components/Flow\"\r\nexport * from \"./components/HlsPlayer\"\r\nexport * from \"./components/InfiniteScroll\"\r\nexport * from \"./components/InputFile\"\r\nexport * from \"./components/LoopSwiper\"\r\nexport * from \"./components/Ring\"\r\nexport * from \"./components/Scroll\"\r\nexport * from \"./components/SectionRing\"\r\nexport * from \"./components/Skeleton\"\r\nexport * from \"./components/TransitionBox\"\r\nexport * from \"./components/TransitionNum\"\r\nexport * from \"./components/Trapezium\"\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,iCAAd;AACA,wBAAc,oCADd;AAEA,wBAAc,0CAFd;AAGA,wBAAc,oCAHd;AAIA,wBAAc,8BAJd;AAKA,wBAAc,mCALd;AAMA,wBAAc,wCANd;AAOA,wBAAc,mCAPd;AAQA,wBAAc,oCARd;AASA,wBAAc,8BATd;AAUA,wBAAc,gCAVd;AAWA,wBAAc,qCAXd;AAYA,wBAAc,kCAZd;AAaA,wBAAc,uCAbd;AAcA,wBAAc,uCAdd;AAeA,wBAAc,mCAfd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoFit.d.ts","sourceRoot":"","sources":["AutoFit.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAc,cAAc,EAAqE,MAAM,OAAO,CAAA;AAGrH,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,cAAc,CAAC;IAChE,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;;OAKG;IACH,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAA;CACjD;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,yGAqElB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoScroll.d.ts","sourceRoot":"","sources":["AutoScroll.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAqF,MAAM,OAAO,CAAA;AAIxH,OAAO,EAAU,WAAW,EAAE,MAAM,UAAU,CAAA;AAE9C,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAChD,cAAc;IACd,KAAK,EAAE,MAAM,CAAA;IAEb,cAAc;IACd,UAAU,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ,WAAW;IACX,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B,WAAW;IACX,cAAc,CAAC,EAAE,aAAa,CAAA;IAE9B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAE1B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,eAAO,MAAM,UAAU,4GA4ErB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoSizeTextarea.d.ts","sourceRoot":"","sources":["AutoSizeTextarea.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAc,sBAAsB,EAA0D,MAAM,OAAO,CAAA;AAGlH;;GAEG;AACH,eAAO,MAAM,gBAAgB,6IAsC3B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircleText.d.ts","sourceRoot":"","sources":["CircleText.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAY,cAAc,EAAE,MAAM,OAAO,CAAA;AAEpD,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC;IACtF,eAAe;IACf,KAAK,EAAE,MAAM,CAAA;IACb,eAAe;IACf,MAAM,EAAE,MAAM,CAAA;IACd,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,8BAA8B;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;IACnC,sBAAsB;IACtB,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAC7B,eAAe;IACf,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,cAAc;IACd,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC,CAAA;IAC1D,YAAY;IACZ,QAAQ,EAAE,MAAM,CAAA;CACnB;AAED,WAAW;AACX,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA2B1C,CAAA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AC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,2CA8FtD;AAED,cAAc;AACd,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,2CAS1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HlsPlayer.d.ts","sourceRoot":"","sources":["HlsPlayer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAsD,MAAM,OAAO,CAAA;AAE/F,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC;IACtF,GAAG,EAAE,MAAM,CAAA;CACd;AAED,eAAO,MAAM,SAAS,6GAwBpB,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ComponentProps, CSSProperties } from "react";
|
|
2
|
+
export type InfiniteScrollProps = ComponentProps<"div"> & {
|
|
3
|
+
/**
|
|
4
|
+
* 滚动的方向
|
|
5
|
+
* @default "vertical"
|
|
6
|
+
*/
|
|
7
|
+
direction?: "vertical" | "horizontal";
|
|
8
|
+
/** 渲染 children 的容器的类名 */
|
|
9
|
+
containerClassName?: string;
|
|
10
|
+
/** 渲染 children 的容器的样式 */
|
|
11
|
+
containerStyle?: CSSProperties;
|
|
12
|
+
/**
|
|
13
|
+
* 两个 children 容器之间的间距
|
|
14
|
+
* @default 0
|
|
15
|
+
*/
|
|
16
|
+
gap?: number;
|
|
17
|
+
/** 一个周期的时间,单位:毫秒 */
|
|
18
|
+
duration: number;
|
|
19
|
+
/** 是否将 gap 的距离也加入 overflow 的计算 */
|
|
20
|
+
withGap?: boolean;
|
|
21
|
+
/** 尺寸刚好相同时,是否视为溢出 */
|
|
22
|
+
withEqual?: boolean;
|
|
23
|
+
/** 鼠标移入时,是否停止动画 */
|
|
24
|
+
pauseOnHover?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 无限滚动的组件
|
|
28
|
+
* 子元素会内置的容器中被渲染两次,首尾相连,形成无限滚动的效果
|
|
29
|
+
* 但是,如果内部检测到并没有溢出,那么不会渲染两次,并且没有动画
|
|
30
|
+
*/
|
|
31
|
+
export declare const InfiniteScroll: import("react").ForwardRefExoticComponent<Omit<InfiniteScrollProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfiniteScroll.d.ts","sourceRoot":"","sources":["InfiniteScroll.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAqF,MAAM,OAAO,CAAA;AAExI,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG;IACtD;;;OAGG;IACH,SAAS,CAAC,EAAE,UAAU,GAAG,YAAY,CAAA;IACrC,yBAAyB;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,yBAAyB;IACzB,cAAc,CAAC,EAAE,aAAa,CAAA;IAC9B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,kCAAkC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,qBAAqB;IACrB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,mBAAmB;IACnB,YAAY,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,6HAmGzB,CAAA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { css } from "@emotion/css";
|
|
2
|
+
import { useSize } from "ahooks";
|
|
3
|
+
import { clsx } from "deepsea-tools";
|
|
4
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
/**
|
|
8
|
+
* 无限滚动的组件
|
|
9
|
+
* 子元素会内置的容器中被渲染两次,首尾相连,形成无限滚动的效果
|
|
10
|
+
* 但是,如果内部检测到并没有溢出,那么不会渲染两次,并且没有动画
|
|
11
|
+
*/
|
|
12
|
+
export const InfiniteScroll = /*#__PURE__*/forwardRef((props, ref) => {
|
|
13
|
+
const {
|
|
14
|
+
className,
|
|
15
|
+
direction = "vertical",
|
|
16
|
+
children,
|
|
17
|
+
containerClassName,
|
|
18
|
+
containerStyle,
|
|
19
|
+
gap = 0,
|
|
20
|
+
duration,
|
|
21
|
+
withGap,
|
|
22
|
+
withEqual,
|
|
23
|
+
pauseOnHover,
|
|
24
|
+
onMouseEnter,
|
|
25
|
+
onMouseLeave,
|
|
26
|
+
...rest
|
|
27
|
+
} = props;
|
|
28
|
+
const wrapper = useRef(null);
|
|
29
|
+
const wrapperSize = useSize(wrapper);
|
|
30
|
+
const ele = useRef(null);
|
|
31
|
+
useImperativeHandle(ref, () => wrapper.current, [wrapper.current]);
|
|
32
|
+
const container = useRef(null);
|
|
33
|
+
const containerSize = useSize(container);
|
|
34
|
+
function bigger(containerSize, wrapperSize) {
|
|
35
|
+
return withEqual ? containerSize + (withGap ? gap : 0) >= wrapperSize : containerSize + (withGap ? gap : 0) > wrapperSize;
|
|
36
|
+
}
|
|
37
|
+
const overflow = wrapperSize && containerSize ? direction === "vertical" ? bigger(containerSize.height, wrapperSize.height) : bigger(containerSize.width, wrapperSize.width) : false;
|
|
38
|
+
const animation = useRef(undefined);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!wrapperSize || !containerSize || !overflow) return;
|
|
41
|
+
animation.current = ele.current?.animate({
|
|
42
|
+
transform: direction === "vertical" ? [`translateY(0)`, `translateY(-${containerSize.height + gap}px)`] : [`translateX(0)`, `translateX(-${containerSize.width + gap}px)`]
|
|
43
|
+
}, {
|
|
44
|
+
duration,
|
|
45
|
+
iterations: Infinity
|
|
46
|
+
});
|
|
47
|
+
return () => animation.current?.cancel();
|
|
48
|
+
}, [wrapperSize, containerSize, overflow, direction, duration]);
|
|
49
|
+
function enter(e) {
|
|
50
|
+
if (pauseOnHover) animation.current?.pause();
|
|
51
|
+
onMouseEnter?.(e);
|
|
52
|
+
}
|
|
53
|
+
function leave(e) {
|
|
54
|
+
if (pauseOnHover) animation.current?.play();
|
|
55
|
+
onMouseLeave?.(e);
|
|
56
|
+
}
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!pauseOnHover) animation.current?.play();
|
|
59
|
+
}, [animation.current, pauseOnHover]);
|
|
60
|
+
return /*#__PURE__*/_jsx("div", {
|
|
61
|
+
ref: wrapper,
|
|
62
|
+
className: clsx(css`
|
|
63
|
+
position: relative;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
`, className),
|
|
66
|
+
onMouseEnter: enter,
|
|
67
|
+
onMouseLeave: leave,
|
|
68
|
+
...rest,
|
|
69
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
70
|
+
ref: ele,
|
|
71
|
+
style: {
|
|
72
|
+
position: "absolute",
|
|
73
|
+
width: direction === "vertical" ? "100%" : containerSize && (overflow ? containerSize.width * 2 + gap : containerSize.width),
|
|
74
|
+
height: direction === "horizontal" ? "100%" : containerSize && (overflow ? containerSize.height * 2 + gap : containerSize.width)
|
|
75
|
+
},
|
|
76
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
77
|
+
ref: container,
|
|
78
|
+
className: clsx(css`
|
|
79
|
+
position: absolute;
|
|
80
|
+
left: 0;
|
|
81
|
+
top: 0;
|
|
82
|
+
${direction === "vertical" ? "width: 100%;" : "height: 100%;"}
|
|
83
|
+
`, containerClassName),
|
|
84
|
+
style: containerStyle,
|
|
85
|
+
children: children
|
|
86
|
+
}), overflow && /*#__PURE__*/_jsx("div", {
|
|
87
|
+
ref: container,
|
|
88
|
+
className: clsx(css`
|
|
89
|
+
position: absolute;
|
|
90
|
+
right: 0;
|
|
91
|
+
bottom: 0;
|
|
92
|
+
${direction === "vertical" ? "width: 100%;" : "height: 100%;"}
|
|
93
|
+
`, containerClassName),
|
|
94
|
+
style: containerStyle,
|
|
95
|
+
children: children
|
|
96
|
+
})]
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=InfiniteScroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["css","useSize","clsx","forwardRef","useEffect","useImperativeHandle","useRef","jsx","_jsx","jsxs","_jsxs","InfiniteScroll","props","ref","className","direction","children","containerClassName","containerStyle","gap","duration","withGap","withEqual","pauseOnHover","onMouseEnter","onMouseLeave","rest","wrapper","wrapperSize","ele","current","container","containerSize","bigger","overflow","height","width","animation","undefined","animate","transform","iterations","Infinity","cancel","enter","e","pause","leave","play","style","position"],"sources":["../../../src/components/InfiniteScroll.tsx"],"sourcesContent":["import { css } from \"@emotion/css\"\r\nimport { useSize } from \"ahooks\"\r\nimport { clsx } from \"deepsea-tools\"\r\nimport { ComponentProps, CSSProperties, forwardRef, MouseEvent as ReactMouseEvent, useEffect, useImperativeHandle, useRef } from \"react\"\r\n\r\nexport type InfiniteScrollProps = ComponentProps<\"div\"> & {\r\n /**\r\n * 滚动的方向\r\n * @default \"vertical\"\r\n */\r\n direction?: \"vertical\" | \"horizontal\"\r\n /** 渲染 children 的容器的类名 */\r\n containerClassName?: string\r\n /** 渲染 children 的容器的样式 */\r\n containerStyle?: CSSProperties\r\n /**\r\n * 两个 children 容器之间的间距\r\n * @default 0\r\n */\r\n gap?: number\r\n /** 一个周期的时间,单位:毫秒 */\r\n duration: number\r\n /** 是否将 gap 的距离也加入 overflow 的计算 */\r\n withGap?: boolean\r\n /** 尺寸刚好相同时,是否视为溢出 */\r\n withEqual?: boolean\r\n /** 鼠标移入时,是否停止动画 */\r\n pauseOnHover?: boolean\r\n}\r\n\r\n/**\r\n * 无限滚动的组件\r\n * 子元素会内置的容器中被渲染两次,首尾相连,形成无限滚动的效果\r\n * 但是,如果内部检测到并没有溢出,那么不会渲染两次,并且没有动画\r\n */\r\nexport const InfiniteScroll = forwardRef<HTMLDivElement, InfiniteScrollProps>((props, ref) => {\r\n const { className, direction = \"vertical\", children, containerClassName, containerStyle, gap = 0, duration, withGap, withEqual, pauseOnHover, onMouseEnter, onMouseLeave, ...rest } = props\r\n\r\n const wrapper = useRef<HTMLDivElement>(null)\r\n const wrapperSize = useSize(wrapper)\r\n\r\n const ele = useRef<HTMLDivElement>(null)\r\n\r\n useImperativeHandle(ref, () => wrapper.current as HTMLDivElement, [wrapper.current])\r\n\r\n const container = useRef<HTMLDivElement>(null)\r\n const containerSize = useSize(container)\r\n\r\n function bigger(containerSize: number, wrapperSize: number) {\r\n return withEqual ? containerSize + (withGap ? gap : 0) >= wrapperSize : containerSize + (withGap ? gap : 0) > wrapperSize\r\n }\r\n\r\n const overflow = wrapperSize && containerSize ? (direction === \"vertical\" ? bigger(containerSize.height, wrapperSize.height) : bigger(containerSize.width, wrapperSize.width)) : false\r\n\r\n const animation = useRef<Animation | undefined>(undefined)\r\n\r\n useEffect(() => {\r\n if (!wrapperSize || !containerSize || !overflow) return\r\n animation.current = ele.current?.animate(\r\n {\r\n transform: direction === \"vertical\" ? [`translateY(0)`, `translateY(-${containerSize.height + gap}px)`] : [`translateX(0)`, `translateX(-${containerSize.width + gap}px)`]\r\n },\r\n { duration, iterations: Infinity }\r\n )\r\n return () => animation.current?.cancel()\r\n }, [wrapperSize, containerSize, overflow, direction, duration])\r\n\r\n function enter(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {\r\n if (pauseOnHover) animation.current?.pause()\r\n onMouseEnter?.(e)\r\n }\r\n\r\n function leave(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {\r\n if (pauseOnHover) animation.current?.play()\r\n onMouseLeave?.(e)\r\n }\r\n\r\n useEffect(() => {\r\n if (!pauseOnHover) animation.current?.play()\r\n }, [animation.current, pauseOnHover])\r\n\r\n return (\r\n <div\r\n ref={wrapper}\r\n className={clsx(\r\n css`\r\n position: relative;\r\n overflow: hidden;\r\n `,\r\n className\r\n )}\r\n onMouseEnter={enter}\r\n onMouseLeave={leave}\r\n {...rest}>\r\n <div\r\n ref={ele}\r\n style={{\r\n position: \"absolute\",\r\n width: direction === \"vertical\" ? \"100%\" : containerSize && (overflow ? containerSize.width * 2 + gap : containerSize.width),\r\n height: direction === \"horizontal\" ? \"100%\" : containerSize && (overflow ? containerSize.height * 2 + gap : containerSize.width)\r\n }}>\r\n <div\r\n ref={container}\r\n className={clsx(\r\n css`\r\n position: absolute;\r\n left: 0;\r\n top: 0;\r\n ${direction === \"vertical\" ? \"width: 100%;\" : \"height: 100%;\"}\r\n `,\r\n containerClassName\r\n )}\r\n style={containerStyle}>\r\n {children}\r\n </div>\r\n {overflow && (\r\n <div\r\n ref={container}\r\n className={clsx(\r\n css`\r\n position: absolute;\r\n right: 0;\r\n bottom: 0;\r\n ${direction === \"vertical\" ? \"width: 100%;\" : \"height: 100%;\"}\r\n `,\r\n containerClassName\r\n )}\r\n style={containerStyle}>\r\n {children}\r\n </div>\r\n )}\r\n </div>\r\n </div>\r\n )\r\n})\r\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,cAAc;AAClC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,IAAI,QAAQ,eAAe;AACpC,SAAwCC,UAAU,EAAiCC,SAAS,EAAEC,mBAAmB,EAAEC,MAAM,QAAQ,OAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AA2BxI;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,gBAAGR,UAAU,CAAsC,CAACS,KAAK,EAAEC,GAAG,KAAK;EAC1F,MAAM;IAAEC,SAAS;IAAEC,SAAS,GAAG,UAAU;IAAEC,QAAQ;IAAEC,kBAAkB;IAAEC,cAAc;IAAEC,GAAG,GAAG,CAAC;IAAEC,QAAQ;IAAEC,OAAO;IAAEC,SAAS;IAAEC,YAAY;IAAEC,YAAY;IAAEC,YAAY;IAAE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ED,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC/D,YAAY;IACZ,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,YAAY;IACZ,SAAS,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAA;IACnC,cAAc;IACd,WAAW,CAAC,EAAE,cAAc,CAAA;CAC/B;AAED,eAAO,MAAM,MAAM,wGA+DjB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionRing.d.ts","sourceRoot":"","sources":["SectionRing.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAE1C,MAAM,WAAW,gBAAiB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACpE,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CAChB;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAuB5C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Skeleton.d.ts","sourceRoot":"","sources":["Skeleton.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAc,cAAc,EAAE,MAAM,OAAO,CAAA;AAElD,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,cAAc,CAAC;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,eAAO,MAAM,QAAQ,0GAmCnB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransitionBox.d.ts","sourceRoot":"","sources":["TransitionBox.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,EAAE,EAAc,cAAc,EAA+B,MAAM,OAAO,CAAA;AAElG,MAAM,WAAW,kBAAmB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACtE,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,cAAc,CAAC,EAAE,aAAa,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,cAAc;AACd,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAqB/C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransitionNum.d.ts","sourceRoot":"","sources":["TransitionNum.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAsD,MAAM,OAAO,CAAA;AAExG,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;IACxF,WAAW;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe;IACf,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB;IAClB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;IAClC,SAAS;IACT,GAAG,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAA;CACvC;AAED,MAAM,WAAW,gBAAgB;IAC7B,GAAG,IAAI,MAAM,CAAA;CAChB;AAED,aAAa;AACb,eAAO,MAAM,aAAa,+GAgCxB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Trapezium.d.ts","sourceRoot":"","sources":["Trapezium.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAc,MAAM,OAAO,CAAA;AAGlD,MAAM,WAAW,cAAe,SAAQ,cAAc,CAAC,cAAc,CAAC;IAClE,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAAA;CACvB;AAED,WAAW;AACX,eAAO,MAAM,SAAS,2GA2CpB,CAAA"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./components/AutoSizeTextarea";
|
|
|
4
4
|
export * from "./components/CircleText";
|
|
5
5
|
export * from "./components/Flow";
|
|
6
6
|
export * from "./components/HlsPlayer";
|
|
7
|
+
export * from "./components/InfiniteScroll";
|
|
7
8
|
export * from "./components/InputFile";
|
|
8
9
|
export * from "./components/LoopSwiper";
|
|
9
10
|
export * from "./components/Ring";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA"}
|
package/dist/esm/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./components/AutoSizeTextarea";
|
|
|
4
4
|
export * from "./components/CircleText";
|
|
5
5
|
export * from "./components/Flow";
|
|
6
6
|
export * from "./components/HlsPlayer";
|
|
7
|
+
export * from "./components/InfiniteScroll";
|
|
7
8
|
export * from "./components/InputFile";
|
|
8
9
|
export * from "./components/LoopSwiper";
|
|
9
10
|
export * from "./components/Ring";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.tsx"],"sourcesContent":["export * from \"./components/AutoFit\"\r\nexport * from \"./components/AutoScroll\"\r\nexport * from \"./components/AutoSizeTextarea\"\r\nexport * from \"./components/CircleText\"\r\nexport * from \"./components/Flow\"\r\nexport * from \"./components/HlsPlayer\"\r\nexport * from \"./components/InputFile\"\r\nexport * from \"./components/LoopSwiper\"\r\nexport * from \"./components/Ring\"\r\nexport * from \"./components/Scroll\"\r\nexport * from \"./components/SectionRing\"\r\nexport * from \"./components/Skeleton\"\r\nexport * from \"./components/TransitionBox\"\r\nexport * from \"./components/TransitionNum\"\r\nexport * from \"./components/Trapezium\"\r\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.tsx"],"sourcesContent":["export * from \"./components/AutoFit\"\r\nexport * from \"./components/AutoScroll\"\r\nexport * from \"./components/AutoSizeTextarea\"\r\nexport * from \"./components/CircleText\"\r\nexport * from \"./components/Flow\"\r\nexport * from \"./components/HlsPlayer\"\r\nexport * from \"./components/InfiniteScroll\"\r\nexport * from \"./components/InputFile\"\r\nexport * from \"./components/LoopSwiper\"\r\nexport * from \"./components/Ring\"\r\nexport * from \"./components/Scroll\"\r\nexport * from \"./components/SectionRing\"\r\nexport * from \"./components/Skeleton\"\r\nexport * from \"./components/TransitionBox\"\r\nexport * from \"./components/TransitionNum\"\r\nexport * from \"./components/Trapezium\"\r\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC,MAAM,MAAM,eAAe,GAAG,KAAK,MAAM,EAAE,CAAA;AAE3C,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;AAE1D,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACvD,CAAC,CAAC,EAAE,eAAe,GAAG,gBAAgB,CAAA;CACzC;AAQD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAEtE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,aAAa,CAQ5H;AAED,wBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEzE"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { css } from "@emotion/css"
|
|
2
|
+
import { useSize } from "ahooks"
|
|
3
|
+
import { clsx } from "deepsea-tools"
|
|
4
|
+
import { ComponentProps, CSSProperties, forwardRef, MouseEvent as ReactMouseEvent, useEffect, useImperativeHandle, useRef } from "react"
|
|
5
|
+
|
|
6
|
+
export type InfiniteScrollProps = ComponentProps<"div"> & {
|
|
7
|
+
/**
|
|
8
|
+
* 滚动的方向
|
|
9
|
+
* @default "vertical"
|
|
10
|
+
*/
|
|
11
|
+
direction?: "vertical" | "horizontal"
|
|
12
|
+
/** 渲染 children 的容器的类名 */
|
|
13
|
+
containerClassName?: string
|
|
14
|
+
/** 渲染 children 的容器的样式 */
|
|
15
|
+
containerStyle?: CSSProperties
|
|
16
|
+
/**
|
|
17
|
+
* 两个 children 容器之间的间距
|
|
18
|
+
* @default 0
|
|
19
|
+
*/
|
|
20
|
+
gap?: number
|
|
21
|
+
/** 一个周期的时间,单位:毫秒 */
|
|
22
|
+
duration: number
|
|
23
|
+
/** 是否将 gap 的距离也加入 overflow 的计算 */
|
|
24
|
+
withGap?: boolean
|
|
25
|
+
/** 尺寸刚好相同时,是否视为溢出 */
|
|
26
|
+
withEqual?: boolean
|
|
27
|
+
/** 鼠标移入时,是否停止动画 */
|
|
28
|
+
pauseOnHover?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 无限滚动的组件
|
|
33
|
+
* 子元素会内置的容器中被渲染两次,首尾相连,形成无限滚动的效果
|
|
34
|
+
* 但是,如果内部检测到并没有溢出,那么不会渲染两次,并且没有动画
|
|
35
|
+
*/
|
|
36
|
+
export const InfiniteScroll = forwardRef<HTMLDivElement, InfiniteScrollProps>((props, ref) => {
|
|
37
|
+
const { className, direction = "vertical", children, containerClassName, containerStyle, gap = 0, duration, withGap, withEqual, pauseOnHover, onMouseEnter, onMouseLeave, ...rest } = props
|
|
38
|
+
|
|
39
|
+
const wrapper = useRef<HTMLDivElement>(null)
|
|
40
|
+
const wrapperSize = useSize(wrapper)
|
|
41
|
+
|
|
42
|
+
const ele = useRef<HTMLDivElement>(null)
|
|
43
|
+
|
|
44
|
+
useImperativeHandle(ref, () => wrapper.current as HTMLDivElement, [wrapper.current])
|
|
45
|
+
|
|
46
|
+
const container = useRef<HTMLDivElement>(null)
|
|
47
|
+
const containerSize = useSize(container)
|
|
48
|
+
|
|
49
|
+
function bigger(containerSize: number, wrapperSize: number) {
|
|
50
|
+
return withEqual ? containerSize + (withGap ? gap : 0) >= wrapperSize : containerSize + (withGap ? gap : 0) > wrapperSize
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const overflow = wrapperSize && containerSize ? (direction === "vertical" ? bigger(containerSize.height, wrapperSize.height) : bigger(containerSize.width, wrapperSize.width)) : false
|
|
54
|
+
|
|
55
|
+
const animation = useRef<Animation | undefined>(undefined)
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!wrapperSize || !containerSize || !overflow) return
|
|
59
|
+
animation.current = ele.current?.animate(
|
|
60
|
+
{
|
|
61
|
+
transform: direction === "vertical" ? [`translateY(0)`, `translateY(-${containerSize.height + gap}px)`] : [`translateX(0)`, `translateX(-${containerSize.width + gap}px)`]
|
|
62
|
+
},
|
|
63
|
+
{ duration, iterations: Infinity }
|
|
64
|
+
)
|
|
65
|
+
return () => animation.current?.cancel()
|
|
66
|
+
}, [wrapperSize, containerSize, overflow, direction, duration])
|
|
67
|
+
|
|
68
|
+
function enter(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {
|
|
69
|
+
if (pauseOnHover) animation.current?.pause()
|
|
70
|
+
onMouseEnter?.(e)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function leave(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {
|
|
74
|
+
if (pauseOnHover) animation.current?.play()
|
|
75
|
+
onMouseLeave?.(e)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!pauseOnHover) animation.current?.play()
|
|
80
|
+
}, [animation.current, pauseOnHover])
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div
|
|
84
|
+
ref={wrapper}
|
|
85
|
+
className={clsx(
|
|
86
|
+
css`
|
|
87
|
+
position: relative;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
`,
|
|
90
|
+
className
|
|
91
|
+
)}
|
|
92
|
+
onMouseEnter={enter}
|
|
93
|
+
onMouseLeave={leave}
|
|
94
|
+
{...rest}>
|
|
95
|
+
<div
|
|
96
|
+
ref={ele}
|
|
97
|
+
style={{
|
|
98
|
+
position: "absolute",
|
|
99
|
+
width: direction === "vertical" ? "100%" : containerSize && (overflow ? containerSize.width * 2 + gap : containerSize.width),
|
|
100
|
+
height: direction === "horizontal" ? "100%" : containerSize && (overflow ? containerSize.height * 2 + gap : containerSize.width)
|
|
101
|
+
}}>
|
|
102
|
+
<div
|
|
103
|
+
ref={container}
|
|
104
|
+
className={clsx(
|
|
105
|
+
css`
|
|
106
|
+
position: absolute;
|
|
107
|
+
left: 0;
|
|
108
|
+
top: 0;
|
|
109
|
+
${direction === "vertical" ? "width: 100%;" : "height: 100%;"}
|
|
110
|
+
`,
|
|
111
|
+
containerClassName
|
|
112
|
+
)}
|
|
113
|
+
style={containerStyle}>
|
|
114
|
+
{children}
|
|
115
|
+
</div>
|
|
116
|
+
{overflow && (
|
|
117
|
+
<div
|
|
118
|
+
ref={container}
|
|
119
|
+
className={clsx(
|
|
120
|
+
css`
|
|
121
|
+
position: absolute;
|
|
122
|
+
right: 0;
|
|
123
|
+
bottom: 0;
|
|
124
|
+
${direction === "vertical" ? "width: 100%;" : "height: 100%;"}
|
|
125
|
+
`,
|
|
126
|
+
containerClassName
|
|
127
|
+
)}
|
|
128
|
+
style={containerStyle}>
|
|
129
|
+
{children}
|
|
130
|
+
</div>
|
|
131
|
+
)}
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
)
|
|
135
|
+
})
|
package/src/index.tsx
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./components/AutoSizeTextarea"
|
|
|
4
4
|
export * from "./components/CircleText"
|
|
5
5
|
export * from "./components/Flow"
|
|
6
6
|
export * from "./components/HlsPlayer"
|
|
7
|
+
export * from "./components/InfiniteScroll"
|
|
7
8
|
export * from "./components/InputFile"
|
|
8
9
|
export * from "./components/LoopSwiper"
|
|
9
10
|
export * from "./components/Ring"
|