@vnejs/uis.react.scroll-content 0.1.5 → 0.1.7
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/ScrollContent.d.ts +2 -10
- package/dist/ScrollContent.d.ts.map +1 -1
- package/dist/ScrollContent.js +1 -1
- package/dist/ScrollContent.js.map +1 -1
- package/dist/ScrollContent.styles.d.ts +1 -1
- package/dist/ScrollContent.styles.d.ts.map +1 -1
- package/dist/ScrollContent.types.d.ts +12 -0
- package/dist/ScrollContent.types.d.ts.map +1 -0
- package/dist/ScrollContent.types.js +2 -0
- package/dist/ScrollContent.types.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ScrollContent.tsx +19 -8
- package/src/ScrollContent.types.tsx +12 -0
- package/src/index.ts +2 -1
- package/tsconfig.json +1 -2
package/dist/ScrollContent.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
children: any;
|
|
4
|
-
shouldScroll: any;
|
|
5
|
-
waitCommonDelay: any;
|
|
6
|
-
waitStartDelay: any;
|
|
7
|
-
waitEndDelay: any;
|
|
8
|
-
duration: any;
|
|
9
|
-
onFinish: any;
|
|
10
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { type ScrollContentProps } from "./ScrollContent.types.js";
|
|
2
|
+
export declare const ScrollContent: ({ className, children, shouldScroll, waitCommonDelay, waitStartDelay, waitEndDelay, duration, onFinish, }: ScrollContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
3
|
//# sourceMappingURL=ScrollContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollContent.d.ts","sourceRoot":"","sources":["../src/ScrollContent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScrollContent.d.ts","sourceRoot":"","sources":["../src/ScrollContent.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAInE,eAAO,MAAM,aAAa,GAAI,2GAS3B,kBAAkB,4CA2DpB,CAAC"}
|
package/dist/ScrollContent.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useRef } from "react";
|
|
3
3
|
import { b } from "./ScrollContent.styles.js";
|
|
4
|
-
export const ScrollContent = ({ className = "", children, shouldScroll, waitCommonDelay, waitStartDelay, waitEndDelay, duration, onFinish }) => {
|
|
4
|
+
export const ScrollContent = ({ className = "", children, shouldScroll, waitCommonDelay, waitStartDelay, waitEndDelay, duration, onFinish, }) => {
|
|
5
5
|
const contentRef = useRef(null);
|
|
6
6
|
const closeTimeout = useRef(0);
|
|
7
7
|
const scrollRequest = useRef(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollContent.js","sourceRoot":"","sources":["../src/ScrollContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ScrollContent.js","sourceRoot":"","sources":["../src/ScrollContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAIvD,OAAO,EAAE,CAAC,EAAE,MAAM,2BAA2B,CAAC;AAE9C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,SAAS,GAAG,EAAE,EACd,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,QAAQ,GACW,EAAE,EAAE;IACvB,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAChD,MAAM,YAAY,GAAG,MAAM,C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AY,CAAC,CAAC;YACpF,CAAC,CAAC,CACH,CAAC;QACJ,CAAC,EAAE,eAAe,GAAG,cAAc,CAAC,CAAC;QAErC,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;IAEjF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,YAAY;YAAE,OAAO;QAEzB,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE;YACzB,oBAAoB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAC5C,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC,EAAE,eAAe,CAAC,CAAC;QAEpB,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC,EAAE,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;IAEpC,OAAO,CACL,cACE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAC7B,GAAG,EAAE,UAAU,YAEd,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const b:
|
|
1
|
+
export declare const b: any;
|
|
2
2
|
//# sourceMappingURL=ScrollContent.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollContent.styles.d.ts","sourceRoot":"","sources":["../src/ScrollContent.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"ScrollContent.styles.d.ts","sourceRoot":"","sources":["../src/ScrollContent.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,CAAC,KAAsB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type ScrollContentProps = {
|
|
3
|
+
className?: string;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
shouldScroll: boolean;
|
|
6
|
+
waitCommonDelay: number;
|
|
7
|
+
waitStartDelay: number;
|
|
8
|
+
waitEndDelay: number;
|
|
9
|
+
duration: number;
|
|
10
|
+
onFinish?: () => void;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=ScrollContent.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollContent.types.d.ts","sourceRoot":"","sources":["../src/ScrollContent.types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollContent.types.js","sourceRoot":"","sources":["../src/ScrollContent.types.tsx"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC"}
|
package/package.json
CHANGED
package/src/ScrollContent.tsx
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef } from "react";
|
|
2
2
|
|
|
3
|
+
import { type ScrollContentProps } from "./ScrollContent.types.js";
|
|
4
|
+
|
|
3
5
|
import { b } from "./ScrollContent.styles.js";
|
|
4
6
|
|
|
5
|
-
export const ScrollContent = ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
export const ScrollContent = ({
|
|
8
|
+
className = "",
|
|
9
|
+
children,
|
|
10
|
+
shouldScroll,
|
|
11
|
+
waitCommonDelay,
|
|
12
|
+
waitStartDelay,
|
|
13
|
+
waitEndDelay,
|
|
14
|
+
duration,
|
|
15
|
+
onFinish,
|
|
16
|
+
}: ScrollContentProps) => {
|
|
17
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
18
|
+
const closeTimeout = useRef<ReturnType<typeof setTimeout>>(0);
|
|
19
|
+
const scrollRequest = useRef<number>(0);
|
|
9
20
|
|
|
10
21
|
const onFinishHandler = useCallback(() => onFinish && onFinish(), [onFinish]);
|
|
11
22
|
|
|
12
23
|
const scrollContent = useCallback(
|
|
13
|
-
(tsStart, path, onEnd) => {
|
|
24
|
+
(tsStart: number, path: number, onEnd: () => void) => {
|
|
14
25
|
const ratio = (new Date().getTime() - tsStart) / duration;
|
|
15
|
-
contentRef.current
|
|
26
|
+
contentRef.current!.scrollTop = path * ratio;
|
|
16
27
|
|
|
17
28
|
if (ratio >= 1) return onEnd();
|
|
18
29
|
|
|
@@ -26,13 +37,13 @@ export const ScrollContent = ({ className = "", children, shouldScroll, waitComm
|
|
|
26
37
|
|
|
27
38
|
if (!shouldScroll) return;
|
|
28
39
|
|
|
29
|
-
contentRef.current
|
|
40
|
+
contentRef.current!.scrollTop = 0;
|
|
30
41
|
|
|
31
42
|
const tm = setTimeout(() => {
|
|
32
43
|
const tsStart = new Date().getTime();
|
|
33
44
|
|
|
34
45
|
scrollRequest.current = requestAnimationFrame(() =>
|
|
35
|
-
scrollContent(tsStart, contentRef.current
|
|
46
|
+
scrollContent(tsStart, contentRef.current!.scrollHeight - contentRef.current!.clientHeight, () => {
|
|
36
47
|
clearTimeout(closeTimeout.current);
|
|
37
48
|
closeTimeout.current = setTimeout(onFinishHandler, waitStartDelay + waitEndDelay);
|
|
38
49
|
}),
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export type ScrollContentProps = {
|
|
4
|
+
className?: string;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
shouldScroll: boolean;
|
|
7
|
+
waitCommonDelay: number;
|
|
8
|
+
waitStartDelay: number;
|
|
9
|
+
waitEndDelay: number;
|
|
10
|
+
duration: number;
|
|
11
|
+
onFinish?: () => void;
|
|
12
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from "./ScrollContent";
|
|
1
|
+
export * from "./ScrollContent.types.js";
|
|
2
|
+
export * from "./ScrollContent.js";
|
package/tsconfig.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "
|
|
2
|
+
"extends": "../../tsconfig.react.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"outDir": "dist",
|
|
5
5
|
"rootDir": "src"
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"src/**/*.ts",
|
|
9
9
|
"src/**/*.tsx",
|
|
10
10
|
"../../../globals.d.ts",
|
|
11
|
-
"../../../peer-modules.d.ts"
|
|
12
11
|
],
|
|
13
12
|
"exclude": [
|
|
14
13
|
"dist",
|