@vnejs/uis.react.scroll-content 0.1.2

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.
@@ -0,0 +1,12 @@
1
+ import "./ScrollContent.styl";
2
+ export declare const ScrollContent: ({ className, children, shouldScroll, waitCommonDelay, waitStartDelay, waitEndDelay, duration, onFinish }: {
3
+ className?: string;
4
+ children: any;
5
+ shouldScroll: any;
6
+ waitCommonDelay: any;
7
+ waitStartDelay: any;
8
+ waitEndDelay: any;
9
+ duration: any;
10
+ onFinish: any;
11
+ }) => import("react/jsx-runtime").JSX.Element;
12
+ //# sourceMappingURL=ScrollContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollContent.d.ts","sourceRoot":"","sources":["../src/ScrollContent.tsx"],"names":[],"mappings":"AAIA,OAAO,sBAAsB,CAAC;AAI9B,eAAO,MAAM,aAAa,GAAI;;;;;;;;;CAA6G,4CA2D1I,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useRef } from "react";
3
+ import { cn } from "@bem-react/classname";
4
+ import "./ScrollContent.styl";
5
+ const b = cn("ScrollContent");
6
+ export const ScrollContent = ({ className = "", children, shouldScroll, waitCommonDelay, waitStartDelay, waitEndDelay, duration, onFinish }) => {
7
+ const contentRef = useRef(null);
8
+ const closeTimeout = useRef(0);
9
+ const scrollRequest = useRef(0);
10
+ const onFinishHandler = useCallback(() => onFinish && onFinish(), [onFinish]);
11
+ const scrollContent = useCallback((tsStart, path, onEnd) => {
12
+ const ratio = (new Date().getTime() - tsStart) / duration;
13
+ contentRef.current.scrollTop = path * ratio;
14
+ if (ratio >= 1)
15
+ return onEnd();
16
+ scrollRequest.current = requestAnimationFrame(() => scrollContent(tsStart, path, onEnd));
17
+ }, [duration]);
18
+ useEffect(() => {
19
+ // показываем
20
+ if (!shouldScroll)
21
+ return;
22
+ contentRef.current.scrollTop = 0;
23
+ const tm = setTimeout(() => {
24
+ const tsStart = new Date().getTime();
25
+ scrollRequest.current = requestAnimationFrame(() => scrollContent(tsStart, contentRef.current.scrollHeight - contentRef.current.clientHeight, () => {
26
+ clearTimeout(closeTimeout.current);
27
+ closeTimeout.current = setTimeout(onFinishHandler, waitStartDelay + waitEndDelay);
28
+ }));
29
+ }, waitCommonDelay + waitStartDelay);
30
+ return () => clearTimeout(tm);
31
+ }, [shouldScroll, waitCommonDelay, waitStartDelay, waitEndDelay, scrollContent]);
32
+ useEffect(() => {
33
+ if (shouldScroll)
34
+ return;
35
+ const tm = setTimeout(() => {
36
+ cancelAnimationFrame(scrollRequest.current);
37
+ clearTimeout(closeTimeout.current);
38
+ }, waitCommonDelay);
39
+ return () => clearTimeout(tm);
40
+ }, [shouldScroll, waitCommonDelay]);
41
+ return (_jsx("div", { className: b({}, [className]), ref: contentRef, children: children }));
42
+ };
43
+ //# sourceMappingURL=ScrollContent.js.map
@@ -0,0 +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;AAEvD,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAE1C,OAAO,sBAAsB,CAAC;AAE9B,MAAM,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;AAE9B,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC7I,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,YAAY,GAAG,MAAM,CAAM,CAAC,CAAC,CAAC;IACpC,MAAM,aAAa,GAAG,MAAM,CAAM,CAAC,CAAC,CAAC;IAErC,MA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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"}
@@ -0,0 +1,8 @@
1
+ .ScrollContent
2
+ display: block
3
+ position: relative
4
+
5
+ width: 100%
6
+ height: 100%
7
+
8
+ overflow: hidden
@@ -0,0 +1,2 @@
1
+ export * from "./ScrollContent";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./ScrollContent";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@vnejs/uis.react.scroll-content",
3
+ "version": "0.1.2",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "scripts": {
7
+ "build": "node ../../scripts/build-package.mjs",
8
+ "publish:major:plugin": "npm run publish:major",
9
+ "publish:minor:plugin": "npm run publish:minor",
10
+ "publish:patch:plugin": "npm run publish:patch",
11
+ "publish:major": "npm run build && npm version major && npm publish --access public",
12
+ "publish:minor": "npm run build && npm version minor && npm publish --access public",
13
+ "publish:patch": "npm run build && npm version patch && npm publish --access public"
14
+ },
15
+ "peerDependencies": {
16
+ "@bem-react/classname": "1.5.12",
17
+ "@vnejs/uis.utils": "~0.1.0",
18
+ "react": "19.2.4",
19
+ "react-dom": "19.2.4"
20
+ },
21
+ "devDependencies": {
22
+ "@vnejs/uis.react": "~0.1.0",
23
+ "typescript": "^5.7.3",
24
+ "@types/react": "^19.0.10",
25
+ "@types/react-dom": "^19.0.4"
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "package.json"
30
+ ]
31
+ }