@ceriousdevtech/vue-cerious-scroll 1.0.1 → 1.0.3
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/CHANGELOG.md +16 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +56 -49
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to vue-cerious-scroll will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.3] - 2026-06-03
|
|
9
|
+
|
|
10
|
+
### Dependencies
|
|
11
|
+
- Bumped peer dependency `@ceriousdevtech/cerious-scroll` to `^1.0.4`. Consumers get smooth wheel scrolling (eased over ~150ms, configurable via `wheel: { smooth }`) and the engine now reads viewport height from `[data-cerious-scroll-content]` so wrappers that put a horizontal scrollbar on the inner element get the last row clearance for free.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- The inner content element is now styled `overflow-y: clip; overflow-x: auto` so consumers can opt into a horizontal scrollbar on the rows axis without a stray vertical bar appearing.
|
|
15
|
+
|
|
16
|
+
## [1.0.2] - 2026-06-03
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- `<CeriousScroll>` now renders its default slot inside the engine container, alongside the engine's scrollbar strip. Combined with a user-supplied `<div data-cerious-scroll-content />`, this lets apps wrap rows in custom DOM (e.g. an `overflow-x: auto` wrapper with a sticky header) without breaking the engine's mobile scrollbar pinning.
|
|
20
|
+
|
|
21
|
+
### Dependencies
|
|
22
|
+
- Bumped peer dependency `@ceriousdevtech/cerious-scroll` to `^1.0.3` to pick up horizontal flick momentum and the custom scrollbar thumb.
|
|
23
|
+
|
|
8
24
|
## [1.0.1] - 2026-06-01
|
|
9
25
|
|
|
10
26
|
### Changed
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),A=require("@ceriousdevtech/cerious-scroll"),V="data-cerious-scroll-content",N="data-cerious-scroll-row";function _(e){const s=e.querySelector(`[${V}]`);if(s)return s;const n=document.createElement("div");return n.setAttribute(V,""),n.style.position="relative",n.style.width="100%",n.style.height="100%",n.style.overflowY="clip",n.style.overflowX="auto",e.appendChild(n),n}function q(e,s){const n=l=>{const r=l.detail;r&&s({percentage:r.percentage,currentElement:r.currentElement,scrollOffset:r.scrollOffset,result:{element:r.result.element,offset:r.result.offset}})},f=l=>{const r=l.detail;r&&s({percentage:r.percentage,currentElement:r.element,scrollOffset:r.scrollOffset,result:{element:r.element,offset:r.scrollOffset}})};return e.addEventListener("cerious-viewport-change",n),e.addEventListener("viewport-change",f),()=>{e.removeEventListener("cerious-viewport-change",n),e.removeEventListener("viewport-change",f)}}function I(e,s){const n=typeof e=="number"?e:typeof s=="number"?s:void 0;if(n===void 0||Number.isNaN(n))throw new Error("useCeriousScroll: provide `totalElements` or `items`.");return Math.max(1,Math.floor(n))}function j(e){var O;const s=(O=o.getCurrentInstance())==null?void 0:O.appContext,n=o.ref(null),f=o.shallowRef(null);let l=null;const r=new Map;let c=null;const C=()=>o.toValue(e.autoRender)??!0,y=t=>{if(e.getItem)return e.getItem(t);const u=o.toValue(e.items);return u?u[t]:void 0},M=(t,u)=>{const i=s??null,m=o.effectScope(!0);return m.run(()=>o.watchEffect(()=>{const E=e.renderItem(y(t),t),d=Array.isArray(E)?E:[E];for(const w of d)o.isVNode(w)&&(w.appContext=i);const a=o.h(o.Fragment,d);a.appContext=i,o.render(a,u)},{flush:"sync"})),()=>m.stop()},b=t=>{t.stop(),o.render(null,t.mount),t.mount.remove()},h=()=>{var w;if(!l)return null;const{scroller:t,contentEl:u,container:i}=l,m=i.clientHeight||i.offsetHeight||0,E=(g,v)=>{const p=document.createElement("div");p.setAttribute(N,String(g)),v.appendChild(p);const S=M(g,p);r.set(g,{el:v,mount:p,stop:S})},d=t.renderViewport(m,u,E),a=new Set(t.getRenderedIndices());return r.forEach((g,v)=>{a.has(v)||(b(g),r.delete(v))}),(w=e.onMeasuredViewport)==null||w.call(e,d),d},R=t=>{if(!l)return;const u=l;l=null,u.unsubscribe(),t&&(c={currentElement:u.scroller.currentElement,scrollOffset:u.scroller.scrollOffset}),r.forEach(i=>b(i)),r.clear(),u.contentEl.textContent="",u.scroller.detachScrollbar(u.container),u.scroller.dispose(),f.value=null},T=t=>{var g,v;const u=_(t),i=e.options??{},m=i.onScroll,E={...i,onScroll:()=>{m==null||m(),C()&&h()}},d=I(o.toValue(e.totalElements),((g=o.toValue(e.items))==null?void 0:g.length)??null),a=new A.CeriousScroll(t,d,E);c&&(a.currentElement=Math.min(c.currentElement,d-1),a.scrollOffset=c.scrollOffset,c=null);const w=q(t,p=>{var S;(S=e.onViewportChange)==null||S.call(e,p)});l={scroller:a,contentEl:u,container:t,unsubscribe:w},f.value=a,(v=e.onReady)==null||v.call(e,a),C()&&requestAnimationFrame(()=>h())},P=()=>{R(!0);const t=n.value;t&&T(t)};return o.onMounted(()=>{const t=n.value;t&&T(t)}),o.onBeforeUnmount(()=>{R(!1)}),o.watch(()=>[o.toValue(e.totalElements),o.toValue(e.items)],()=>{var u;if(!l)return;const t=I(o.toValue(e.totalElements),((u=o.toValue(e.items))==null?void 0:u.length)??null);l.scroller.totalElements!==t&&P()}),{containerRef:n,scroller:f,render:h,jumpToElement:t=>l?(l.scroller.jumpToElement(t),h()):null,scrollToPercentage:t=>l?(l.scroller.handleScrollPercentage(t),h()):null,reset:()=>l?(l.scroller.reset(),h()):null,recalculate:()=>l?(l.scroller.clearAllCaches(),h()):null}}const F=o.defineComponent({name:"CeriousScroll",props:{totalElements:{type:Number,default:null},items:{type:Array,default:null},getItem:{type:Function,default:void 0},renderItem:{type:Function,default:void 0},options:{type:Object,default:void 0},autoRender:{type:Boolean,default:!0}},emits:{"viewport-change":e=>!0,"measured-viewport":e=>!0,ready:e=>!0},setup(e,{slots:s,emit:n,expose:f}){const l=(c,C)=>{var y;return e.renderItem?e.renderItem(c,C):(y=s.item)==null?void 0:y.call(s,{item:c,index:C})},r=j({totalElements:()=>e.totalElements,items:()=>e.items,getItem:e.getItem?c=>e.getItem(c):void 0,renderItem:l,options:e.options,autoRender:()=>e.autoRender,onViewportChange:c=>n("viewport-change",c),onMeasuredViewport:c=>n("measured-viewport",c),onReady:c=>n("ready",c)});return f({scroller:r.scroller,render:r.render,jumpToElement:r.jumpToElement,scrollToPercentage:r.scrollToPercentage,reset:r.reset,recalculate:r.recalculate}),()=>{var c;return o.h("div",{ref:r.containerRef,style:{position:"relative",overflow:"hidden"}},(c=s.default)==null?void 0:c.call(s))}}});Object.defineProperty(exports,"CeriousScrollEngine",{enumerable:!0,get:()=>A.CeriousScroll});exports.CeriousScroll=F;exports.useCeriousScroll=j;
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { getCurrentInstance as P, ref as _, shallowRef as x, onMounted as F, onBeforeUnmount as L, watch as $, toValue as
|
|
2
|
-
import { CeriousScroll as
|
|
1
|
+
import { getCurrentInstance as P, ref as _, shallowRef as x, onMounted as F, onBeforeUnmount as L, watch as $, toValue as v, render as O, effectScope as q, watchEffect as B, isVNode as H, h as M, Fragment as U, defineComponent as W } from "vue";
|
|
2
|
+
import { CeriousScroll as X } from "@ceriousdevtech/cerious-scroll";
|
|
3
3
|
import { CeriousScroll as oe } from "@ceriousdevtech/cerious-scroll";
|
|
4
|
-
const A = "data-cerious-scroll-content",
|
|
5
|
-
function
|
|
4
|
+
const A = "data-cerious-scroll-content", Y = "data-cerious-scroll-row";
|
|
5
|
+
function z(e) {
|
|
6
6
|
const s = e.querySelector(`[${A}]`);
|
|
7
7
|
if (s) return s;
|
|
8
8
|
const n = document.createElement("div");
|
|
9
|
-
return n.setAttribute(A, ""), n.style.position = "relative", n.style.width = "100%", n.style.height = "100%", n.style.
|
|
9
|
+
return n.setAttribute(A, ""), n.style.position = "relative", n.style.width = "100%", n.style.height = "100%", n.style.overflowY = "clip", n.style.overflowX = "auto", e.appendChild(n), n;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function D(e, s) {
|
|
12
12
|
const n = (o) => {
|
|
13
13
|
const r = o.detail;
|
|
14
14
|
r && s({
|
|
@@ -36,17 +36,17 @@ function V(e, s) {
|
|
|
36
36
|
throw new Error("useCeriousScroll: provide `totalElements` or `items`.");
|
|
37
37
|
return Math.max(1, Math.floor(n));
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function G(e) {
|
|
40
40
|
var I;
|
|
41
41
|
const s = (I = P()) == null ? void 0 : I.appContext, n = _(null), a = x(null);
|
|
42
42
|
let o = null;
|
|
43
43
|
const r = /* @__PURE__ */ new Map();
|
|
44
|
-
let
|
|
45
|
-
const C = () =>
|
|
44
|
+
let l = null;
|
|
45
|
+
const C = () => v(e.autoRender) ?? !0, y = (t) => {
|
|
46
46
|
if (e.getItem) return e.getItem(t);
|
|
47
|
-
const
|
|
48
|
-
return
|
|
49
|
-
}, N = (t,
|
|
47
|
+
const c = v(e.items);
|
|
48
|
+
return c ? c[t] : void 0;
|
|
49
|
+
}, N = (t, c) => {
|
|
50
50
|
const u = s ?? null, f = q(!0);
|
|
51
51
|
return f.run(
|
|
52
52
|
() => B(
|
|
@@ -55,46 +55,46 @@ function K(e) {
|
|
|
55
55
|
for (const w of m)
|
|
56
56
|
H(w) && (w.appContext = u);
|
|
57
57
|
const i = M(U, m);
|
|
58
|
-
i.appContext = u, O(i,
|
|
58
|
+
i.appContext = u, O(i, c);
|
|
59
59
|
},
|
|
60
60
|
{ flush: "sync" }
|
|
61
61
|
)
|
|
62
62
|
), () => f.stop();
|
|
63
63
|
}, S = (t) => {
|
|
64
64
|
t.stop(), O(null, t.mount), t.mount.remove();
|
|
65
|
-
},
|
|
65
|
+
}, h = () => {
|
|
66
66
|
var w;
|
|
67
67
|
if (!o) return null;
|
|
68
|
-
const { scroller: t, contentEl:
|
|
68
|
+
const { scroller: t, contentEl: c, container: u } = o, f = u.clientHeight || u.offsetHeight || 0, E = (d, g) => {
|
|
69
69
|
const p = document.createElement("div");
|
|
70
|
-
p.setAttribute(
|
|
70
|
+
p.setAttribute(Y, String(d)), g.appendChild(p);
|
|
71
71
|
const R = N(d, p);
|
|
72
72
|
r.set(d, { el: g, mount: p, stop: R });
|
|
73
|
-
}, m = t.renderViewport(f,
|
|
73
|
+
}, m = t.renderViewport(f, c, E), i = new Set(t.getRenderedIndices());
|
|
74
74
|
return r.forEach((d, g) => {
|
|
75
75
|
i.has(g) || (S(d), r.delete(g));
|
|
76
76
|
}), (w = e.onMeasuredViewport) == null || w.call(e, m), m;
|
|
77
77
|
}, T = (t) => {
|
|
78
78
|
if (!o) return;
|
|
79
|
-
const
|
|
80
|
-
o = null,
|
|
81
|
-
currentElement:
|
|
82
|
-
scrollOffset:
|
|
83
|
-
}), r.forEach((u) => S(u)), r.clear(),
|
|
79
|
+
const c = o;
|
|
80
|
+
o = null, c.unsubscribe(), t && (l = {
|
|
81
|
+
currentElement: c.scroller.currentElement,
|
|
82
|
+
scrollOffset: c.scroller.scrollOffset
|
|
83
|
+
}), r.forEach((u) => S(u)), r.clear(), c.contentEl.textContent = "", c.scroller.detachScrollbar(c.container), c.scroller.dispose(), a.value = null;
|
|
84
84
|
}, b = (t) => {
|
|
85
85
|
var d, g;
|
|
86
|
-
const
|
|
86
|
+
const c = z(t), u = e.options ?? {}, f = u.onScroll, E = {
|
|
87
87
|
...u,
|
|
88
88
|
onScroll: () => {
|
|
89
|
-
f == null || f(), C() &&
|
|
89
|
+
f == null || f(), C() && h();
|
|
90
90
|
}
|
|
91
|
-
}, m = V(
|
|
92
|
-
|
|
93
|
-
const w =
|
|
91
|
+
}, m = V(v(e.totalElements), ((d = v(e.items)) == null ? void 0 : d.length) ?? null), i = new X(t, m, E);
|
|
92
|
+
l && (i.currentElement = Math.min(l.currentElement, m - 1), i.scrollOffset = l.scrollOffset, l = null);
|
|
93
|
+
const w = D(t, (p) => {
|
|
94
94
|
var R;
|
|
95
95
|
(R = e.onViewportChange) == null || R.call(e, p);
|
|
96
96
|
});
|
|
97
|
-
o = { scroller: i, contentEl:
|
|
97
|
+
o = { scroller: i, contentEl: c, container: t, unsubscribe: w }, a.value = i, (g = e.onReady) == null || g.call(e, i), C() && requestAnimationFrame(() => h());
|
|
98
98
|
}, j = () => {
|
|
99
99
|
T(!0);
|
|
100
100
|
const t = n.value;
|
|
@@ -106,21 +106,21 @@ function K(e) {
|
|
|
106
106
|
}), L(() => {
|
|
107
107
|
T(!1);
|
|
108
108
|
}), $(
|
|
109
|
-
() => [
|
|
109
|
+
() => [v(e.totalElements), v(e.items)],
|
|
110
110
|
() => {
|
|
111
|
-
var
|
|
111
|
+
var c;
|
|
112
112
|
if (!o) return;
|
|
113
|
-
const t = V(
|
|
113
|
+
const t = V(v(e.totalElements), ((c = v(e.items)) == null ? void 0 : c.length) ?? null);
|
|
114
114
|
o.scroller.totalElements !== t && j();
|
|
115
115
|
}
|
|
116
116
|
), {
|
|
117
117
|
containerRef: n,
|
|
118
118
|
scroller: a,
|
|
119
|
-
render:
|
|
120
|
-
jumpToElement: (t) => o ? (o.scroller.jumpToElement(t),
|
|
121
|
-
scrollToPercentage: (t) => o ? (o.scroller.handleScrollPercentage(t),
|
|
122
|
-
reset: () => o ? (o.scroller.reset(),
|
|
123
|
-
recalculate: () => o ? (o.scroller.clearAllCaches(),
|
|
119
|
+
render: h,
|
|
120
|
+
jumpToElement: (t) => o ? (o.scroller.jumpToElement(t), h()) : null,
|
|
121
|
+
scrollToPercentage: (t) => o ? (o.scroller.handleScrollPercentage(t), h()) : null,
|
|
122
|
+
reset: () => o ? (o.scroller.reset(), h()) : null,
|
|
123
|
+
recalculate: () => o ? (o.scroller.clearAllCaches(), h()) : null
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
const te = W({
|
|
@@ -151,21 +151,21 @@ const te = W({
|
|
|
151
151
|
ready: (e) => !0
|
|
152
152
|
},
|
|
153
153
|
setup(e, { slots: s, emit: n, expose: a }) {
|
|
154
|
-
const o = (
|
|
154
|
+
const o = (l, C) => {
|
|
155
155
|
var y;
|
|
156
|
-
return e.renderItem ? e.renderItem(
|
|
157
|
-
}, r =
|
|
156
|
+
return e.renderItem ? e.renderItem(l, C) : (y = s.item) == null ? void 0 : y.call(s, { item: l, index: C });
|
|
157
|
+
}, r = G({
|
|
158
158
|
totalElements: () => e.totalElements,
|
|
159
159
|
items: () => e.items,
|
|
160
|
-
getItem: e.getItem ? (
|
|
160
|
+
getItem: e.getItem ? (l) => e.getItem(l) : void 0,
|
|
161
161
|
renderItem: o,
|
|
162
162
|
// Engine options are consumed at creation; reading the prop once matches
|
|
163
163
|
// that contract (remount via `:key` to apply new engine options).
|
|
164
164
|
options: e.options,
|
|
165
165
|
autoRender: () => e.autoRender,
|
|
166
|
-
onViewportChange: (
|
|
167
|
-
onMeasuredViewport: (
|
|
168
|
-
onReady: (
|
|
166
|
+
onViewportChange: (l) => n("viewport-change", l),
|
|
167
|
+
onMeasuredViewport: (l) => n("measured-viewport", l),
|
|
168
|
+
onReady: (l) => n("ready", l)
|
|
169
169
|
});
|
|
170
170
|
return a({
|
|
171
171
|
/** The underlying engine instance (`null` before mount). */
|
|
@@ -175,15 +175,22 @@ const te = W({
|
|
|
175
175
|
scrollToPercentage: r.scrollToPercentage,
|
|
176
176
|
reset: r.reset,
|
|
177
177
|
recalculate: r.recalculate
|
|
178
|
-
}), () =>
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
178
|
+
}), () => {
|
|
179
|
+
var l;
|
|
180
|
+
return M(
|
|
181
|
+
"div",
|
|
182
|
+
{
|
|
183
|
+
ref: r.containerRef,
|
|
184
|
+
// User-supplied class/style/attrs fall through and merge onto this root.
|
|
185
|
+
style: { position: "relative", overflow: "hidden" }
|
|
186
|
+
},
|
|
187
|
+
(l = s.default) == null ? void 0 : l.call(s)
|
|
188
|
+
);
|
|
189
|
+
};
|
|
183
190
|
}
|
|
184
191
|
});
|
|
185
192
|
export {
|
|
186
193
|
te as CeriousScroll,
|
|
187
194
|
oe as CeriousScrollEngine,
|
|
188
|
-
|
|
195
|
+
G as useCeriousScroll
|
|
189
196
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ceriousdevtech/vue-cerious-scroll",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Vue 3 bindings for CeriousScroll — high-performance virtual scrolling with O(1) memory and no height estimation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -56,12 +56,14 @@
|
|
|
56
56
|
"demo": "vite --config demo/vite.config.ts",
|
|
57
57
|
"demo:build": "vite build --config demo/vite.config.ts"
|
|
58
58
|
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@ceriousdevtech/cerious-scroll": "^1.0.4"
|
|
61
|
+
},
|
|
59
62
|
"peerDependencies": {
|
|
60
|
-
"@ceriousdevtech/cerious-scroll": "^1.0.1",
|
|
61
63
|
"vue": "^3.3.0"
|
|
62
64
|
},
|
|
63
65
|
"devDependencies": {
|
|
64
|
-
"@
|
|
66
|
+
"@tanstack/vue-virtual": "^3.10.8",
|
|
65
67
|
"@types/node": "^22.10.2",
|
|
66
68
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
67
69
|
"@vue/test-utils": "^2.4.6",
|