@quantabit/scroll-sdk 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 QuantaBit Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # @quantabit/scroll-sdk
2
+
3
+ > Universal scroll utilities: BackToTop, ScrollProgress, and hooks
4
+
5
+ ## Features
6
+
7
+ - **BackToTop** — Auto-showing floating button
8
+ - **ScrollProgress** — Page reading progress bar
9
+ - **useScrollPosition** — Track scroll position and progress %
10
+ - **useInfiniteScroll** — Infinite scroll with loading state
11
+ - **useScrollDirection** — Detect 'up' or 'down' scrolling
12
+ - **Scroll Utils** — scrollToTop, scrollToElement, scrollToBottom
13
+
14
+ ## Quick Start
15
+
16
+ ```jsx
17
+ import { BackToTop, ScrollProgress, useScrollDirection } from '@quantabit/scroll-sdk';
18
+
19
+ function App() {
20
+ const direction = useScrollDirection();
21
+ return (
22
+ <>
23
+ <ScrollProgress color="#3b82f6" />
24
+ <BackToTop threshold={300} />
25
+ </>
26
+ );
27
+ }
28
+ ```
29
+
30
+ ## License
31
+
32
+ MIT © QuantaBit Team
33
+
34
+
35
+
36
+ ---
37
+
38
+ ## 🌐 Brand & Links
39
+ - Official Mainnet: [QuantaBit Chain](https://qbitchain.io/)
40
+ - Developer Platform: [Developer Platform](https://developer.quantabit.io/)
41
+ - Open Platform: [Open Platform](https://open.quantabit.io/)
42
+ - Payment Platform: [Pay Platform](https://pay.qbitwallet.io/)
43
+ - Feedback: [Feedback](https://xwin.live/qbit)
package/dist/index.cjs ADDED
@@ -0,0 +1,222 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ function useScrollPosition(throttleMs = 100) {
6
+ const [pos, setPos] = React.useState({
7
+ x: 0,
8
+ y: 0,
9
+ progress: 0
10
+ });
11
+ const timer = React.useRef(null);
12
+ React.useEffect(() => {
13
+ const handler = () => {
14
+ if (timer.current) return;
15
+ timer.current = setTimeout(() => {
16
+ const y = window.scrollY;
17
+ const maxY = document.documentElement.scrollHeight - window.innerHeight;
18
+ setPos({
19
+ x: window.scrollX,
20
+ y,
21
+ progress: maxY > 0 ? Math.min(1, y / maxY) : 0
22
+ });
23
+ timer.current = null;
24
+ }, throttleMs);
25
+ };
26
+ window.addEventListener('scroll', handler, {
27
+ passive: true
28
+ });
29
+ return () => window.removeEventListener('scroll', handler);
30
+ }, [throttleMs]);
31
+ return pos;
32
+ }
33
+
34
+ function scrollToTop(smooth = true) {
35
+ window.scrollTo({
36
+ top: 0,
37
+ behavior: smooth ? 'smooth' : 'auto'
38
+ });
39
+ }
40
+ function scrollToBottom(smooth = true) {
41
+ window.scrollTo({
42
+ top: document.body.scrollHeight,
43
+ behavior: smooth ? 'smooth' : 'auto'
44
+ });
45
+ }
46
+ function scrollToElement(selector, offset = 0, smooth = true) {
47
+ const el = document.querySelector(selector);
48
+ if (!el) return;
49
+ const y = el.getBoundingClientRect().top + window.scrollY - offset;
50
+ window.scrollTo({
51
+ top: y,
52
+ behavior: smooth ? 'smooth' : 'auto'
53
+ });
54
+ }
55
+
56
+ function BackToTop({
57
+ threshold = 300,
58
+ size = 44,
59
+ className = '',
60
+ style = {}
61
+ }) {
62
+ const {
63
+ y
64
+ } = useScrollPosition();
65
+ if (y < threshold) return null;
66
+ return /*#__PURE__*/React.createElement("button", {
67
+ className: `qs-back-to-top ${className}`,
68
+ onClick: () => scrollToTop(),
69
+ "aria-label": "Back to top",
70
+ style: {
71
+ position: 'fixed',
72
+ bottom: 24,
73
+ right: 24,
74
+ zIndex: 9000,
75
+ width: size,
76
+ height: size,
77
+ borderRadius: '50%',
78
+ border: 'none',
79
+ cursor: 'pointer',
80
+ background: 'rgba(24,24,27,0.9)',
81
+ color: '#fff',
82
+ display: 'flex',
83
+ alignItems: 'center',
84
+ justifyContent: 'center',
85
+ boxShadow: '0 4px 16px rgba(0,0,0,0.15)',
86
+ transition: 'all 0.3s',
87
+ animation: 'qs-fade-in 0.3s ease-out',
88
+ ...style
89
+ }
90
+ }, /*#__PURE__*/React.createElement("svg", {
91
+ width: "18",
92
+ height: "18",
93
+ viewBox: "0 0 24 24",
94
+ fill: "none",
95
+ stroke: "currentColor",
96
+ strokeWidth: "2.5"
97
+ }, /*#__PURE__*/React.createElement("path", {
98
+ d: "M18 15l-6-6-6 6",
99
+ strokeLinecap: "round",
100
+ strokeLinejoin: "round"
101
+ })));
102
+ }
103
+
104
+ function ScrollProgress({
105
+ color = '#3b82f6',
106
+ height = 3,
107
+ zIndex = 10000,
108
+ className = ''
109
+ }) {
110
+ const {
111
+ progress
112
+ } = useScrollPosition(16);
113
+ return /*#__PURE__*/React.createElement("div", {
114
+ className: `qs-progress ${className}`,
115
+ style: {
116
+ position: 'fixed',
117
+ top: 0,
118
+ left: 0,
119
+ right: 0,
120
+ height,
121
+ zIndex,
122
+ background: 'transparent',
123
+ pointerEvents: 'none'
124
+ }
125
+ }, /*#__PURE__*/React.createElement("div", {
126
+ style: {
127
+ height: '100%',
128
+ width: `${progress * 100}%`,
129
+ background: color,
130
+ transition: 'width 50ms linear',
131
+ borderRadius: '0 2px 2px 0'
132
+ }
133
+ }));
134
+ }
135
+
136
+ function useInfiniteScroll(callback, options = {}) {
137
+ const {
138
+ threshold = 200,
139
+ enabled = true
140
+ } = options;
141
+ const loading = React.useRef(false);
142
+ const handleScroll = React.useCallback(() => {
143
+ if (!enabled || loading.current) return;
144
+ const {
145
+ scrollHeight,
146
+ scrollTop,
147
+ clientHeight
148
+ } = document.documentElement;
149
+ if (scrollHeight - scrollTop - clientHeight < threshold) {
150
+ loading.current = true;
151
+ Promise.resolve(callback()).finally(() => {
152
+ loading.current = false;
153
+ });
154
+ }
155
+ }, [callback, threshold, enabled]);
156
+ React.useEffect(() => {
157
+ window.addEventListener('scroll', handleScroll, {
158
+ passive: true
159
+ });
160
+ return () => window.removeEventListener('scroll', handleScroll);
161
+ }, [handleScroll]);
162
+ }
163
+
164
+ function useScrollDirection(threshold = 10) {
165
+ const [dir, setDir] = React.useState('none');
166
+ const lastY = React.useRef(0);
167
+ React.useEffect(() => {
168
+ const handler = () => {
169
+ const y = window.scrollY;
170
+ if (Math.abs(y - lastY.current) > threshold) {
171
+ setDir(y > lastY.current ? 'down' : 'up');
172
+ }
173
+ lastY.current = y;
174
+ };
175
+ window.addEventListener('scroll', handler, {
176
+ passive: true
177
+ });
178
+ return () => window.removeEventListener('scroll', handler);
179
+ }, [threshold]);
180
+ return dir;
181
+ }
182
+
183
+ const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];
184
+ const messages = {
185
+ en: {
186
+ "scroll.top": "Back to top"
187
+ },
188
+ zh: {
189
+ "scroll.top": "回到顶部"
190
+ },
191
+ ja: {
192
+ "scroll.top": "トップに戻る"
193
+ },
194
+ ko: {
195
+ "scroll.top": "위로 가기"
196
+ }
197
+ };
198
+ let currentLang = 'en';
199
+ function setLanguage(l) {
200
+ if (SUPPORTED_LANGUAGES.includes(l)) currentLang = l;
201
+ }
202
+ function getLanguage() {
203
+ return currentLang;
204
+ }
205
+ function t(k) {
206
+ return messages[currentLang]?.[k] || messages.en?.[k] || k;
207
+ }
208
+
209
+ exports.BackToTop = BackToTop;
210
+ exports.SUPPORTED_LANGUAGES = SUPPORTED_LANGUAGES;
211
+ exports.ScrollProgress = ScrollProgress;
212
+ exports.getLanguage = getLanguage;
213
+ exports.messages = messages;
214
+ exports.scrollToBottom = scrollToBottom;
215
+ exports.scrollToElement = scrollToElement;
216
+ exports.scrollToTop = scrollToTop;
217
+ exports.setLanguage = setLanguage;
218
+ exports.t = t;
219
+ exports.useInfiniteScroll = useInfiniteScroll;
220
+ exports.useScrollDirection = useScrollDirection;
221
+ exports.useScrollPosition = useScrollPosition;
222
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/hooks/useScrollPosition.js","../src/utils/scroll.js","../src/components/BackToTop.jsx","../src/components/ScrollProgress.jsx","../src/hooks/useInfiniteScroll.js","../src/hooks/useScrollDirection.js","../src/i18n/index.js"],"sourcesContent":["import{useState,useEffect,useRef}from'react';\nexport function useScrollPosition(throttleMs=100){\n const[pos,setPos]=useState({x:0,y:0,progress:0});\n const timer=useRef(null);\n useEffect(()=>{const handler=()=>{if(timer.current)return;timer.current=setTimeout(()=>{const y=window.scrollY;const maxY=document.documentElement.scrollHeight-window.innerHeight;setPos({x:window.scrollX,y,progress:maxY>0?Math.min(1,y/maxY):0});timer.current=null;},throttleMs);};\n window.addEventListener('scroll',handler,{passive:true});return()=>window.removeEventListener('scroll',handler);},[throttleMs]);\n return pos;\n}\n","export function scrollToTop(smooth=true){window.scrollTo({top:0,behavior:smooth?'smooth':'auto'});}\nexport function scrollToBottom(smooth=true){window.scrollTo({top:document.body.scrollHeight,behavior:smooth?'smooth':'auto'});}\nexport function scrollToElement(selector,offset=0,smooth=true){const el=document.querySelector(selector);if(!el)return;const y=el.getBoundingClientRect().top+window.scrollY-offset;window.scrollTo({top:y,behavior:smooth?'smooth':'auto'});}\n","import React from 'react';\nimport { useScrollPosition } from '../hooks/useScrollPosition';\nimport { scrollToTop } from '../utils/scroll';\nexport function BackToTop({ threshold=300, size=44, className='', style={} }) {\n const { y } = useScrollPosition();\n if (y < threshold) return null;\n return (\n <button className={`qs-back-to-top ${className}`} onClick={()=>scrollToTop()} aria-label=\"Back to top\"\n style={{ position:'fixed', bottom:24, right:24, zIndex:9000, width:size, height:size, borderRadius:'50%',\n border:'none', cursor:'pointer', background:'rgba(24,24,27,0.9)', color:'#fff',\n display:'flex', alignItems:'center', justifyContent:'center',\n boxShadow:'0 4px 16px rgba(0,0,0,0.15)', transition:'all 0.3s',\n animation:'qs-fade-in 0.3s ease-out', ...style }}>\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.5\">\n <path d=\"M18 15l-6-6-6 6\" strokeLinecap=\"round\" strokeLinejoin=\"round\"/>\n </svg>\n </button>\n );\n}\n","import React from 'react';\nimport { useScrollPosition } from '../hooks/useScrollPosition';\nexport function ScrollProgress({ color='#3b82f6', height=3, zIndex=10000, className='' }) {\n const { progress } = useScrollPosition(16);\n return (\n <div className={`qs-progress ${className}`} style={{ position:'fixed', top:0, left:0, right:0, height, zIndex, background:'transparent', pointerEvents:'none' }}>\n <div style={{ height:'100%', width:`${progress*100}%`, background:color, transition:'width 50ms linear', borderRadius:'0 2px 2px 0' }} />\n </div>\n );\n}\n","import{useEffect,useRef,useCallback}from'react';\nexport function useInfiniteScroll(callback,options={}){\n const{threshold=200,enabled=true}=options;\n const loading=useRef(false);\n const handleScroll=useCallback(()=>{if(!enabled||loading.current)return;const{scrollHeight,scrollTop,clientHeight}=document.documentElement;if(scrollHeight-scrollTop-clientHeight<threshold){loading.current=true;Promise.resolve(callback()).finally(()=>{loading.current=false;});}\n },[callback,threshold,enabled]);\n useEffect(()=>{window.addEventListener('scroll',handleScroll,{passive:true});return()=>window.removeEventListener('scroll',handleScroll);},[handleScroll]);\n}\n","import{useState,useEffect,useRef}from'react';\nexport function useScrollDirection(threshold=10){\n const[dir,setDir]=useState('none');\n const lastY=useRef(0);\n useEffect(()=>{const handler=()=>{const y=window.scrollY;if(Math.abs(y-lastY.current)>threshold){setDir(y>lastY.current?'down':'up');}lastY.current=y;};\n window.addEventListener('scroll',handler,{passive:true});return()=>window.removeEventListener('scroll',handler);},[threshold]);\n return dir;\n}\n","export const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];\nexport const messages = {\n en: {\n \"scroll.top\": \"Back to top\"\n},\n zh: {\n \"scroll.top\": \"回到顶部\"\n},\n ja: {\n \"scroll.top\": \"トップに戻る\"\n},\n ko: {\n \"scroll.top\": \"위로 가기\"\n}\n};\nlet currentLang = 'en';\nexport function setLanguage(l) { if (SUPPORTED_LANGUAGES.includes(l)) currentLang = l; }\nexport function getLanguage() { return currentLang; }\nexport function t(k) { return messages[currentLang]?.[k] || messages.en?.[k] || k; }\n"],"names":["useScrollPosition","throttleMs","pos","setPos","useState","x","y","progress","timer","useRef","useEffect","handler","current","setTimeout","window","scrollY","maxY","document","documentElement","scrollHeight","innerHeight","scrollX","Math","min","addEventListener","passive","removeEventListener","scrollToTop","smooth","scrollTo","top","behavior","scrollToBottom","body","scrollToElement","selector","offset","el","querySelector","getBoundingClientRect","BackToTop","threshold","size","className","style","React","createElement","onClick","position","bottom","right","zIndex","width","height","borderRadius","border","cursor","background","color","display","alignItems","justifyContent","boxShadow","transition","animation","viewBox","fill","stroke","strokeWidth","d","strokeLinecap","strokeLinejoin","ScrollProgress","left","pointerEvents","useInfiniteScroll","callback","options","enabled","loading","handleScroll","useCallback","scrollTop","clientHeight","Promise","resolve","finally","useScrollDirection","dir","setDir","lastY","abs","SUPPORTED_LANGUAGES","messages","en","zh","ja","ko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C,QAAQ,EAACf,OAAO,CAAC;AAAC,EAAA,CAAC,EAAC,CAAC8B,SAAS,CAAC,CAAC;AAC9H,EAAA,OAAO+C,GAAG;AACZ;;ACPO,MAAMI,mBAAmB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;AACnD,MAAMC,QAAQ,GAAG;AACtBC,EAAAA,EAAE,EAAE;AACJ,IAAA,YAAY,EAAE;GACf;AACCC,EAAAA,EAAE,EAAE;AACJ,IAAA,YAAY,EAAE;GACf;AACCC,EAAAA,EAAE,EAAE;AACJ,IAAA,YAAY,EAAE;GACf;AACCC,EAAAA,EAAE,EAAE;AACJ,IAAA,YAAY,EAAE;AAChB;AACA;AACA,IAAIC,WAAW,GAAG,IAAI;AACf,SAASC,WAAWA,CAACC,CAAC,EAAE;EAAE,IAAIR,mBAAmB,CAACS,QAAQ,CAACD,CAAC,CAAC,EAAEF,WAAW,GAAGE,CAAC;AAAE;AAChF,SAASE,WAAWA,GAAG;AAAE,EAAA,OAAOJ,WAAW;AAAE;AAC7C,SAASK,CAACA,CAACC,CAAC,EAAE;AAAE,EAAA,OAAOX,QAAQ,CAACK,WAAW,CAAC,GAAGM,CAAC,CAAC,IAAIX,QAAQ,CAACC,EAAE,GAAGU,CAAC,CAAC,IAAIA,CAAC;AAAE;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,208 @@
1
+ import React, { useState, useRef, useEffect, useCallback } from 'react';
2
+
3
+ function useScrollPosition(throttleMs = 100) {
4
+ const [pos, setPos] = useState({
5
+ x: 0,
6
+ y: 0,
7
+ progress: 0
8
+ });
9
+ const timer = useRef(null);
10
+ useEffect(() => {
11
+ const handler = () => {
12
+ if (timer.current) return;
13
+ timer.current = setTimeout(() => {
14
+ const y = window.scrollY;
15
+ const maxY = document.documentElement.scrollHeight - window.innerHeight;
16
+ setPos({
17
+ x: window.scrollX,
18
+ y,
19
+ progress: maxY > 0 ? Math.min(1, y / maxY) : 0
20
+ });
21
+ timer.current = null;
22
+ }, throttleMs);
23
+ };
24
+ window.addEventListener('scroll', handler, {
25
+ passive: true
26
+ });
27
+ return () => window.removeEventListener('scroll', handler);
28
+ }, [throttleMs]);
29
+ return pos;
30
+ }
31
+
32
+ function scrollToTop(smooth = true) {
33
+ window.scrollTo({
34
+ top: 0,
35
+ behavior: smooth ? 'smooth' : 'auto'
36
+ });
37
+ }
38
+ function scrollToBottom(smooth = true) {
39
+ window.scrollTo({
40
+ top: document.body.scrollHeight,
41
+ behavior: smooth ? 'smooth' : 'auto'
42
+ });
43
+ }
44
+ function scrollToElement(selector, offset = 0, smooth = true) {
45
+ const el = document.querySelector(selector);
46
+ if (!el) return;
47
+ const y = el.getBoundingClientRect().top + window.scrollY - offset;
48
+ window.scrollTo({
49
+ top: y,
50
+ behavior: smooth ? 'smooth' : 'auto'
51
+ });
52
+ }
53
+
54
+ function BackToTop({
55
+ threshold = 300,
56
+ size = 44,
57
+ className = '',
58
+ style = {}
59
+ }) {
60
+ const {
61
+ y
62
+ } = useScrollPosition();
63
+ if (y < threshold) return null;
64
+ return /*#__PURE__*/React.createElement("button", {
65
+ className: `qs-back-to-top ${className}`,
66
+ onClick: () => scrollToTop(),
67
+ "aria-label": "Back to top",
68
+ style: {
69
+ position: 'fixed',
70
+ bottom: 24,
71
+ right: 24,
72
+ zIndex: 9000,
73
+ width: size,
74
+ height: size,
75
+ borderRadius: '50%',
76
+ border: 'none',
77
+ cursor: 'pointer',
78
+ background: 'rgba(24,24,27,0.9)',
79
+ color: '#fff',
80
+ display: 'flex',
81
+ alignItems: 'center',
82
+ justifyContent: 'center',
83
+ boxShadow: '0 4px 16px rgba(0,0,0,0.15)',
84
+ transition: 'all 0.3s',
85
+ animation: 'qs-fade-in 0.3s ease-out',
86
+ ...style
87
+ }
88
+ }, /*#__PURE__*/React.createElement("svg", {
89
+ width: "18",
90
+ height: "18",
91
+ viewBox: "0 0 24 24",
92
+ fill: "none",
93
+ stroke: "currentColor",
94
+ strokeWidth: "2.5"
95
+ }, /*#__PURE__*/React.createElement("path", {
96
+ d: "M18 15l-6-6-6 6",
97
+ strokeLinecap: "round",
98
+ strokeLinejoin: "round"
99
+ })));
100
+ }
101
+
102
+ function ScrollProgress({
103
+ color = '#3b82f6',
104
+ height = 3,
105
+ zIndex = 10000,
106
+ className = ''
107
+ }) {
108
+ const {
109
+ progress
110
+ } = useScrollPosition(16);
111
+ return /*#__PURE__*/React.createElement("div", {
112
+ className: `qs-progress ${className}`,
113
+ style: {
114
+ position: 'fixed',
115
+ top: 0,
116
+ left: 0,
117
+ right: 0,
118
+ height,
119
+ zIndex,
120
+ background: 'transparent',
121
+ pointerEvents: 'none'
122
+ }
123
+ }, /*#__PURE__*/React.createElement("div", {
124
+ style: {
125
+ height: '100%',
126
+ width: `${progress * 100}%`,
127
+ background: color,
128
+ transition: 'width 50ms linear',
129
+ borderRadius: '0 2px 2px 0'
130
+ }
131
+ }));
132
+ }
133
+
134
+ function useInfiniteScroll(callback, options = {}) {
135
+ const {
136
+ threshold = 200,
137
+ enabled = true
138
+ } = options;
139
+ const loading = useRef(false);
140
+ const handleScroll = useCallback(() => {
141
+ if (!enabled || loading.current) return;
142
+ const {
143
+ scrollHeight,
144
+ scrollTop,
145
+ clientHeight
146
+ } = document.documentElement;
147
+ if (scrollHeight - scrollTop - clientHeight < threshold) {
148
+ loading.current = true;
149
+ Promise.resolve(callback()).finally(() => {
150
+ loading.current = false;
151
+ });
152
+ }
153
+ }, [callback, threshold, enabled]);
154
+ useEffect(() => {
155
+ window.addEventListener('scroll', handleScroll, {
156
+ passive: true
157
+ });
158
+ return () => window.removeEventListener('scroll', handleScroll);
159
+ }, [handleScroll]);
160
+ }
161
+
162
+ function useScrollDirection(threshold = 10) {
163
+ const [dir, setDir] = useState('none');
164
+ const lastY = useRef(0);
165
+ useEffect(() => {
166
+ const handler = () => {
167
+ const y = window.scrollY;
168
+ if (Math.abs(y - lastY.current) > threshold) {
169
+ setDir(y > lastY.current ? 'down' : 'up');
170
+ }
171
+ lastY.current = y;
172
+ };
173
+ window.addEventListener('scroll', handler, {
174
+ passive: true
175
+ });
176
+ return () => window.removeEventListener('scroll', handler);
177
+ }, [threshold]);
178
+ return dir;
179
+ }
180
+
181
+ const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];
182
+ const messages = {
183
+ en: {
184
+ "scroll.top": "Back to top"
185
+ },
186
+ zh: {
187
+ "scroll.top": "回到顶部"
188
+ },
189
+ ja: {
190
+ "scroll.top": "トップに戻る"
191
+ },
192
+ ko: {
193
+ "scroll.top": "위로 가기"
194
+ }
195
+ };
196
+ let currentLang = 'en';
197
+ function setLanguage(l) {
198
+ if (SUPPORTED_LANGUAGES.includes(l)) currentLang = l;
199
+ }
200
+ function getLanguage() {
201
+ return currentLang;
202
+ }
203
+ function t(k) {
204
+ return messages[currentLang]?.[k] || messages.en?.[k] || k;
205
+ }
206
+
207
+ export { BackToTop, SUPPORTED_LANGUAGES, ScrollProgress, getLanguage, messages, scrollToBottom, scrollToElement, scrollToTop, setLanguage, t, useInfiniteScroll, useScrollDirection, useScrollPosition };
208
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/hooks/useScrollPosition.js","../src/utils/scroll.js","../src/components/BackToTop.jsx","../src/components/ScrollProgress.jsx","../src/hooks/useInfiniteScroll.js","../src/hooks/useScrollDirection.js","../src/i18n/index.js"],"sourcesContent":["import{useState,useEffect,useRef}from'react';\nexport function useScrollPosition(throttleMs=100){\n const[pos,setPos]=useState({x:0,y:0,progress:0});\n const timer=useRef(null);\n useEffect(()=>{const handler=()=>{if(timer.current)return;timer.current=setTimeout(()=>{const y=window.scrollY;const maxY=document.documentElement.scrollHeight-window.innerHeight;setPos({x:window.scrollX,y,progress:maxY>0?Math.min(1,y/maxY):0});timer.current=null;},throttleMs);};\n window.addEventListener('scroll',handler,{passive:true});return()=>window.removeEventListener('scroll',handler);},[throttleMs]);\n return pos;\n}\n","export function scrollToTop(smooth=true){window.scrollTo({top:0,behavior:smooth?'smooth':'auto'});}\nexport function scrollToBottom(smooth=true){window.scrollTo({top:document.body.scrollHeight,behavior:smooth?'smooth':'auto'});}\nexport function scrollToElement(selector,offset=0,smooth=true){const el=document.querySelector(selector);if(!el)return;const y=el.getBoundingClientRect().top+window.scrollY-offset;window.scrollTo({top:y,behavior:smooth?'smooth':'auto'});}\n","import React from 'react';\nimport { useScrollPosition } from '../hooks/useScrollPosition';\nimport { scrollToTop } from '../utils/scroll';\nexport function BackToTop({ threshold=300, size=44, className='', style={} }) {\n const { y } = useScrollPosition();\n if (y < threshold) return null;\n return (\n <button className={`qs-back-to-top ${className}`} onClick={()=>scrollToTop()} aria-label=\"Back to top\"\n style={{ position:'fixed', bottom:24, right:24, zIndex:9000, width:size, height:size, borderRadius:'50%',\n border:'none', cursor:'pointer', background:'rgba(24,24,27,0.9)', color:'#fff',\n display:'flex', alignItems:'center', justifyContent:'center',\n boxShadow:'0 4px 16px rgba(0,0,0,0.15)', transition:'all 0.3s',\n animation:'qs-fade-in 0.3s ease-out', ...style }}>\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.5\">\n <path d=\"M18 15l-6-6-6 6\" strokeLinecap=\"round\" strokeLinejoin=\"round\"/>\n </svg>\n </button>\n );\n}\n","import React from 'react';\nimport { useScrollPosition } from '../hooks/useScrollPosition';\nexport function ScrollProgress({ color='#3b82f6', height=3, zIndex=10000, className='' }) {\n const { progress } = useScrollPosition(16);\n return (\n <div className={`qs-progress ${className}`} style={{ position:'fixed', top:0, left:0, right:0, height, zIndex, background:'transparent', pointerEvents:'none' }}>\n <div style={{ height:'100%', width:`${progress*100}%`, background:color, transition:'width 50ms linear', borderRadius:'0 2px 2px 0' }} />\n </div>\n );\n}\n","import{useEffect,useRef,useCallback}from'react';\nexport function useInfiniteScroll(callback,options={}){\n const{threshold=200,enabled=true}=options;\n const loading=useRef(false);\n const handleScroll=useCallback(()=>{if(!enabled||loading.current)return;const{scrollHeight,scrollTop,clientHeight}=document.documentElement;if(scrollHeight-scrollTop-clientHeight<threshold){loading.current=true;Promise.resolve(callback()).finally(()=>{loading.current=false;});}\n },[callback,threshold,enabled]);\n useEffect(()=>{window.addEventListener('scroll',handleScroll,{passive:true});return()=>window.removeEventListener('scroll',handleScroll);},[handleScroll]);\n}\n","import{useState,useEffect,useRef}from'react';\nexport function useScrollDirection(threshold=10){\n const[dir,setDir]=useState('none');\n const lastY=useRef(0);\n useEffect(()=>{const handler=()=>{const y=window.scrollY;if(Math.abs(y-lastY.current)>threshold){setDir(y>lastY.current?'down':'up');}lastY.current=y;};\n window.addEventListener('scroll',handler,{passive:true});return()=>window.removeEventListener('scroll',handler);},[threshold]);\n return dir;\n}\n","export const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];\nexport const messages = {\n en: {\n \"scroll.top\": \"Back to top\"\n},\n zh: {\n \"scroll.top\": \"回到顶部\"\n},\n ja: {\n \"scroll.top\": \"トップに戻る\"\n},\n ko: {\n \"scroll.top\": \"위로 가기\"\n}\n};\nlet currentLang = 'en';\nexport function setLanguage(l) { if (SUPPORTED_LANGUAGES.includes(l)) currentLang = l; }\nexport function getLanguage() { return currentLang; }\nexport function t(k) { return messages[currentLang]?.[k] || messages.en?.[k] || k; }\n"],"names":["useScrollPosition","throttleMs","pos","setPos","useState","x","y","progress","timer","useRef","useEffect","handler","current","setTimeout","window","scrollY","maxY","document","documentElement","scrollHeight","innerHeight","scrollX","Math","min","addEventListener","passive","removeEventListener","scrollToTop","smooth","scrollTo","top","behavior","scrollToBottom","body","scrollToElement","selector","offset","el","querySelector","getBoundingClientRect","BackToTop","threshold","size","className","style","React","createElement","onClick","position","bottom","right","zIndex","width","height","borderRadius","border","cursor","background","color","display","alignItems","justifyContent","boxShadow","transition","animation","viewBox","fill","stroke","strokeWidth","d","strokeLinecap","strokeLinejoin","ScrollProgress","left","pointerEvents","useInfiniteScroll","callback","options","enabled","loading","handleScroll","useCallback","scrollTop","clientHeight","Promise","resolve","finally","useScrollDirection","dir","setDir","lastY","abs","SUPPORTED_LANGUAGES","messages","en","zh","ja","ko","currentLang","setLanguage","l","includes","getLanguage","t","k"],"mappings":";;AACO,SAASA,iBAAiBA,CAACC,UAAU,GAAC,GAAG,EAAC;AAC/C,EAAA,MAAK,CAACC,GAAG,EAACC,MAAM,CAAC,GAACC,QAAQ,CAAC;AAACC,IAAAA,CAAC,EAAC,CAAC;AAACC,IAAAA,CAAC,EAAC,CAAC;AAACC,IAAAA,QAAQ,EAAC;AAAC,GAAC,CAAC;AAChD,EAAA,MAAMC,KAAK,GAACC,MAAM,CAAC,IAAI,CAAC;AACxBC,EAAAA,SAAS,CAAC,MAAI;IAAC,MAAMC,OAAO,GAACA,MAAI;MAAC,IAAGH,KAAK,CAACI,OAAO,EAAC;AAAOJ,MAAAA,KAAK,CAACI,OAAO,GAACC,UAAU,CAAC,MAAI;AAAC,QAAA,MAAMP,CAAC,GAACQ,MAAM,CAACC,OAAO;QAAC,MAAMC,IAAI,GAACC,QAAQ,CAACC,eAAe,CAACC,YAAY,GAACL,MAAM,CAACM,WAAW;AAACjB,QAAAA,MAAM,CAAC;UAACE,CAAC,EAACS,MAAM,CAACO,OAAO;UAACf,CAAC;AAACC,UAAAA,QAAQ,EAACS,IAAI,GAAC,CAAC,GAACM,IAAI,CAACC,GAAG,CAAC,CAAC,EAACjB,CAAC,GAACU,IAAI,CAAC,GAAC;AAAC,SAAC,CAAC;QAACR,KAAK,CAACI,OAAO,GAAC,IAAI;MAAC,CAAC,EAACX,UAAU,CAAC;IAAC,CAAC;AACvRa,IAAAA,MAAM,CAACU,gBAAgB,CAAC,QAAQ,EAACb,OAAO,EAAC;AAACc,MAAAA,OAAO,EAAC;AAAI,KAAC,CAAC;IAAC,OAAM,MAAIX,MAAM,CAACY,mBAAmB,CAAC,QAAQ,EAACf,OAAO,CAAC;AAAC,EAAA,CAAC,EAAC,CAACV,UAAU,C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Q,EAACb,OAAO,EAAC;AAACc,MAAAA,OAAO,EAAC;AAAI,KAAC,CAAC;IAAC,OAAM,MAAIX,MAAM,CAACY,mBAAmB,CAAC,QAAQ,EAACf,OAAO,CAAC;AAAC,EAAA,CAAC,EAAC,CAAC8B,SAAS,CAAC,CAAC;AAC9H,EAAA,OAAO+C,GAAG;AACZ;;ACPO,MAAMI,mBAAmB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;AACnD,MAAMC,QAAQ,GAAG;AACtBC,EAAAA,EAAE,EAAE;AACJ,IAAA,YAAY,EAAE;GACf;AACCC,EAAAA,EAAE,EAAE;AACJ,IAAA,YAAY,EAAE;GACf;AACCC,EAAAA,EAAE,EAAE;AACJ,IAAA,YAAY,EAAE;GACf;AACCC,EAAAA,EAAE,EAAE;AACJ,IAAA,YAAY,EAAE;AAChB;AACA;AACA,IAAIC,WAAW,GAAG,IAAI;AACf,SAASC,WAAWA,CAACC,CAAC,EAAE;EAAE,IAAIR,mBAAmB,CAACS,QAAQ,CAACD,CAAC,CAAC,EAAEF,WAAW,GAAGE,CAAC;AAAE;AAChF,SAASE,WAAWA,GAAG;AAAE,EAAA,OAAOJ,WAAW;AAAE;AAC7C,SAASK,CAACA,CAACC,CAAC,EAAE;AAAE,EAAA,OAAOX,QAAQ,CAACK,WAAW,CAAC,GAAGM,CAAC,CAAC,IAAIX,QAAQ,CAACC,EAAE,GAAGU,CAAC,CAAC,IAAIA,CAAC;AAAE;;;;"}
@@ -0,0 +1,2 @@
1
+ @keyframes qs-fade-in{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.qs-back-to-top:hover{box-shadow:0 8px 24px rgba(0,0,0,.2)!important;transform:scale(1.1)!important}
2
+ /*# sourceMappingURL=styles.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["scroll.css"],"names":[],"mappings":"AAAA,sBAAwB,GAAK,SAAS,CAAC,0BAA0B,CAAE,GAAG,SAAS,CAAC,uBAAuB,CAAE,CACzG,sBAAyD,8CAAgD,CAAjF,8BAAmF","file":"styles.css","sourcesContent":["@keyframes qs-fade-in { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }\n.qs-back-to-top:hover { transform:scale(1.1) !important; box-shadow:0 8px 24px rgba(0,0,0,0.2) !important; }\n"]}
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@quantabit/scroll-sdk",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "Universal scroll utilities: BackToTop, ScrollProgress, infinite scroll, scroll direction hooks",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.esm.js",
8
+ "types": "types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./types/index.d.ts",
12
+ "import": "./dist/index.esm.js",
13
+ "require": "./dist/index.cjs"
14
+ },
15
+ "./styles": "./dist/styles.css",
16
+ "./styles.css": "./dist/styles.css"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "types",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "scripts": {
25
+ "build": "rollup -c",
26
+ "dev": "rollup -c -w",
27
+ "test": "jest --passWithNoTests",
28
+ "prepublishOnly": "npm run build"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/quantabit-chain/qbit-sdk.git",
33
+ "directory": "packages/scroll-sdk"
34
+ },
35
+ "homepage": "https://github.com/quantabit-chain/qbit-sdk/tree/main/packages/scroll-sdk",
36
+ "bugs": {
37
+ "url": "https://github.com/quantabit-chain/qbit-sdk/issues"
38
+ },
39
+ "keywords": [
40
+ "scroll",
41
+ "back-to-top",
42
+ "infinite-scroll",
43
+ "progress",
44
+ "react",
45
+ "quantabit"
46
+ ],
47
+ "author": "QuantaBit Team",
48
+ "license": "MIT",
49
+ "engines": {
50
+ "node": ">=18.0.0"
51
+ },
52
+ "peerDependencies": {
53
+ "react": ">=17.0.0",
54
+ "react-dom": ">=17.0.0"
55
+ },
56
+ "dependencies": {
57
+ "@quantabit/sdk-config": "^1.0.6"
58
+ },
59
+ "publishConfig": {
60
+ "access": "public"
61
+ },
62
+ "sideEffects": [
63
+ "*.css"
64
+ ],
65
+ "qbit": {
66
+ "privacy": {
67
+ "level": "functional",
68
+ "dataCollection": "Feature-related data for personalization. Requires user consent.",
69
+ "gdprCompliant": true,
70
+ "ccpaCompliant": true
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @quantabit/scroll-sdk TypeScript Type Definitions
3
+ *
4
+ * Auto-generated type stubs. Enhance with specific types as the SDK matures.
5
+ */
6
+
7
+ import { FC, ReactNode } from 'react';
8
+
9
+ // ============ Components ============
10
+
11
+ export interface BackToTopProps {
12
+ className?: string;
13
+ style?: React.CSSProperties;
14
+ [key: string]: any;
15
+ }
16
+
17
+ export declare const BackToTop: FC<BackToTopProps>;
18
+
19
+ export interface ScrollProgressProps {
20
+ className?: string;
21
+ style?: React.CSSProperties;
22
+ [key: string]: any;
23
+ }
24
+
25
+ export declare const ScrollProgress: FC<ScrollProgressProps>;
26
+
27
+ // ============ Hooks ============
28
+
29
+ export interface UseScrollPositionReturn {
30
+ data: any;
31
+ loading: boolean;
32
+ error: string | null;
33
+ [key: string]: any;
34
+ }
35
+
36
+ export declare function useScrollPosition(...args: any[]): UseScrollPositionReturn;
37
+
38
+ export interface UseInfiniteScrollReturn {
39
+ data: any;
40
+ loading: boolean;
41
+ error: string | null;
42
+ [key: string]: any;
43
+ }
44
+
45
+ export declare function useInfiniteScroll(...args: any[]): UseInfiniteScrollReturn;
46
+
47
+ export interface UseScrollDirectionReturn {
48
+ data: any;
49
+ loading: boolean;
50
+ error: string | null;
51
+ [key: string]: any;
52
+ }
53
+
54
+ export declare function useScrollDirection(...args: any[]): UseScrollDirectionReturn;
55
+
56
+ // ============ Functions & Utilities ============
57
+
58
+ export declare function scrollToTop(...args: any[]): any;
59
+ export declare function scrollToElement(...args: any[]): any;
60
+ export declare function scrollToBottom(...args: any[]): any;
61
+ export declare const messages: Record<string, Record<string, string>>;
62
+ export declare const SUPPORTED_LANGUAGES: string[];
63
+ export declare function setLanguage(lang: string): void;
64
+ export declare function getLanguage(): string;
65
+ export declare function t(key: string, params?: Record<string, any>): string;
66
+