@oxog/scrollex 1.0.0 → 1.1.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/CHANGELOG.md +86 -5
- package/README.md +30 -22
- package/dist/chunk-CIB3EBBJ.js +734 -0
- package/dist/chunk-CIB3EBBJ.js.map +1 -0
- package/dist/chunk-ND5PV5MU.cjs +747 -0
- package/dist/chunk-ND5PV5MU.cjs.map +1 -0
- package/dist/index.cjs +677 -961
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -784
- package/dist/index.d.ts +5 -784
- package/dist/index.js +651 -949
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.cjs +255 -766
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.cts +61 -560
- package/dist/plugins/index.d.ts +61 -560
- package/dist/plugins/index.js +236 -761
- package/dist/plugins/index.js.map +1 -1
- package/dist/scroll-controller-D5AV1E2p.d.cts +809 -0
- package/dist/scroll-controller-D5AV1E2p.d.ts +809 -0
- package/package.json +30 -13
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,84 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.1.0] - 2026-11-30
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- `VirtualList`, `VirtualGrid` and `VirtualMasonry`: an `onLoadMore` started by scrolling that rejects (or throws) is logged as `[Scrollex] Error in onLoadMore:` instead of becoming an unhandled promise rejection, the same as a load started for a list that does not fill its viewport.
|
|
14
|
+
- `bidirectional` passed inline (`plugins={[bidirectional(...)]}`) keeps following the bottom when new items arrive: the instance that saw the new items was replaced in the same commit and its scroll to the bottom was dropped.
|
|
15
|
+
- `scrollRestoration` no longer stops saving for good when the saved position is past the end of a list that stays shorter: once the reader scrolls, the wait for more data ends and the position is saved on unmount again.
|
|
16
|
+
- `kernel.destroy()` (and the event bus's `clear` / `clearEvent`) called from inside an event handler stops the handlers it removed from running for the rest of that event, as `off()` already did.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- `@oxog/scrollex` and `@oxog/scrollex/plugins` are built together with code splitting: the core plugins exported by both entry points are now the same functions and share their per-kernel state (each entry used to bundle its own copy).
|
|
20
|
+
- `react-dom` is an optional peer dependency (`peerDependenciesMeta`): the package never imports it.
|
|
21
|
+
- `exports` lists `./package.json`.
|
|
22
|
+
- Releases are published by a manually started `Publish` workflow (npm trusted publishing with provenance) instead of on a pushed `v*` tag; `npm run prepublishOnly` runs lint, typecheck, tests with coverage, the build and a check of the packed archive.
|
|
23
|
+
|
|
24
|
+
### Internal
|
|
25
|
+
- ESLint 9 with `typescript-eslint` covers `src` and `tests` with no warnings allowed; `typecheck` also checks the tests (`tsconfig.test.json`).
|
|
26
|
+
- `npm run test:package` packs the archive, installs it with React into a scratch project, imports both entry points through ESM and CommonJS, type-checks them under `NodeNext` and runs smoke tests (including server rendering in plain Node). CI runs it on Node 18, 20, 22 and 24; lint, typecheck, tests and build run on Node 22 and 24.
|
|
27
|
+
- The documented-browser-versions test matched no version at all (its pattern lost its backslashes in a template literal) and a masonry gap test asserted nothing; both now check what they describe.
|
|
28
|
+
|
|
29
|
+
## [1.0.3] - 2026-11-27
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
- Releases are cut by the `Publish` workflow from a `v*` tag: it checks the tag against `package.json` and that the version is not already on npm before installing anything, then builds, tests and publishes the tagged commit with a provenance attestation.
|
|
33
|
+
- A prerelease version such as `1.0.4-beta.0` publishes under its own dist-tag (`beta`), so a test release can be installed with `@beta` without moving `latest`.
|
|
34
|
+
- No source file changed since 1.0.2: this release ships the same code with the release process now living in the repository, and `CI` no longer runs on tags, so `Publish` is the only workflow a release triggers.
|
|
35
|
+
|
|
36
|
+
### Internal
|
|
37
|
+
- CI and tests only, no runtime change: the suite runs on the `vmThreads` pool behind a coverage gate that `CI` enforces; the documentation website is installed with `npm ci`, typechecked and built in `CI`, and the Pages deploy waits for those checks and runs off Node 20; `prismjs` is deduped onto 1.30.0.
|
|
38
|
+
- The `1.0.x` changelog version links point at their tag pages instead of commit ranges.
|
|
39
|
+
- `npm run build` cleans `dist` once, before `tsup` starts: the first tsup config used to clean it while the plugins config was writing `dist/plugins`, which occasionally left `plugins/index.d.ts` and `plugins/index.d.cts` out of the build; the same command now also fails loudly if any of the 12 expected `dist` files is missing after `tsup` finishes, so a partial build can never reach npm.
|
|
40
|
+
|
|
41
|
+
## [1.0.2] - 2026-11-24
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
- `engines` reports `>= 18.0.0` again: both published bundles import only `react` and `react/jsx-runtime`, so the Node 22.18 floor that the current test and build tools need is a development-only constraint and no longer warns installers of the package.
|
|
45
|
+
- The toolchain requirement is declared in `devEngines` (`^22.18.0 || ^24.11.0 || >=26.0.0`, `onFail: "warn"`), which npm checks when a contributor installs the project.
|
|
46
|
+
- CI runs on Node 24 and still runs `npm ci`, typecheck, the test suite and the build.
|
|
47
|
+
|
|
48
|
+
### Security
|
|
49
|
+
- Updated the dev-only dependency tree to clear the reachable Dependabot advisories: `vitest` and `@vitest/coverage-v8` 5.1.1, `tsup` 9.0.0, and the website's React Router 7.18.7, Vite 8.3.8 and `@vitejs/plugin-react` 6.3.0. Nothing shipped changed: `dist` still imports only React.
|
|
50
|
+
|
|
51
|
+
### Removed
|
|
52
|
+
- Unused `vitepress` devDependency and its `docs:*` scripts, which pointed at a `docs/` directory that does not exist.
|
|
53
|
+
|
|
54
|
+
## [1.0.1] - 2026-11-24
|
|
55
|
+
|
|
56
|
+
### Changed
|
|
57
|
+
- `Range.endIndex` is now the last item that is at least partly inside the viewport (inclusive, as documented). It used to be one past it, so a row starting exactly at the edge counted as visible.
|
|
58
|
+
- `useVirtualList` / `createKernel` accept `paddingStart` (`KernelOptions.paddingStart`); `initialScrollOffset` is applied once on mount.
|
|
59
|
+
- `keyboardNav`: with nothing focused, `ArrowDown` / `ArrowRight` focus the first item and other keys no longer move the focus; `Enter` / `Space` only act on a focused item.
|
|
60
|
+
- `VirtualList` ARIA: options carry `aria-setsize` / `aria-posinset` (the position among all items) instead of the unsupported `aria-rowcount` / `aria-rowindex`; a horizontal list exposes `aria-orientation="horizontal"`.
|
|
61
|
+
- `DragHandleProps` handlers are typed with the new `DragEventLike` so they can be spread on React elements; `UseMeasureOptions`, `UseMeasureReturn` and `DragEventLike` are exported.
|
|
62
|
+
|
|
63
|
+
### Fixed
|
|
64
|
+
- Hooks: `virtualItems` never contains items beyond the data in the render where the data shrinks (`items[virtualItem.index]` no longer throws).
|
|
65
|
+
- A smooth scroll keeps running when a masonry's items, columns or gap change.
|
|
66
|
+
- Item counts: measurements of removed items are dropped when the list shrinks; `measureItem` ignores invalid sizes and indices; entries that are `undefined` are rendered like any other item.
|
|
67
|
+
- Plugins created inline on every render (`plugins={[...]}`) keep their state per list: `infiniteLoaderPlugin` (load in flight), `keyboardNav` (focus), `dragToReorder` (drag in progress), `bidirectional` / `scrollRestoration` (one-time actions).
|
|
68
|
+
- Infinite loading: horizontal lists measure the end along their own axis, and a list that does not fill its viewport asks for more data.
|
|
69
|
+
- Grid: `aria-rowcount` is right right after mounting and after count changes; `overscan` changes take effect.
|
|
70
|
+
- Scroll engine: negative or non-finite animation durations scroll instantly; the position cache follows the clamped scroll position.
|
|
71
|
+
- Debug panel counts and percentage, masonry row visibility, `useMeasureMany` observation and several documentation samples were corrected.
|
|
72
|
+
- `keyboardNav`: `PageUp` / `PageDown` stop at the ends with `loop` on (arrow keys still wrap), and in a grid the focused item's whole row is scrolled into view.
|
|
73
|
+
- `scrollRestoration` restores the position of a new `key` on a list that stays mounted; `EventBus` once-handlers follow the same dispatch snapshot as other handlers.
|
|
74
|
+
- Layout inputs: `columns` that is not a positive whole number (0, a fraction, NaN) and `overscan` that is NaN or negative no longer break or empty the list/grid/masonry; a masonry item with a non-finite height no longer poisons the layout.
|
|
75
|
+
- Website: icon-only controls in the header and footer have accessible names.
|
|
76
|
+
- `columns="auto"` with an unusable `minColumnWidth` (0, negative, NaN) lays out one column instead of crashing the masonry / emptying the grid; `stickyHeaders` follows the axis of a horizontal list; masonry column heights end at each column's last item (no trailing gap) and the renderer reports an empty layout once uninstalled.
|
|
77
|
+
- `kernel.getScrollPosition()` now fills `offset` (position along the list's axis) and `percentage` (0-1); the debug panel's viewport overlay and item boundaries switches are documented as not implemented.
|
|
78
|
+
- Horizontal lists: `infiniteLoaderPlugin`, `autoMeasurerPlugin` and `bidirectional` follow the list's own axis (`scrollLeft` / width) instead of `scrollTop` / height.
|
|
79
|
+
- `infiniteLoaderPlugin` loads for a list that fits its viewport (it looks once at install); `scrollRestoration` waits for data that arrives after mount and no longer overwrites the saved position; `initialScrollOffset` also works when the list is empty at mount.
|
|
80
|
+
- Scroll events of programmatic scrolls carry their delta and direction; a smooth scroll never starts backward (its first frame can precede the start time).
|
|
81
|
+
- Grid and masonry size their columns from the content box of a padded container; `useVirtualGrid` no longer accepts list-only options it ignores (`estimatedItemHeight`, `horizontal`, `paddingStart`, `paddingEnd`, `scrollMargin`); `GridRendererOptions.getContainerWidth` is new.
|
|
82
|
+
- `infiniteLoaderPlugin`'s `reset()` drops the check its debounce window queued for the data being replaced, so a reset list no longer loads for the position it had in the old data.
|
|
83
|
+
- Removing items rebuilds the measured count and size sum from the entries that remain: a shifted measurement that lands on an index that is still measured no longer leaves both overstated.
|
|
84
|
+
- A programmatic scroll stopped from inside a frame (a host that reports the scroll synchronously) really ends: the running frame neither schedules another one nor clears the state of a newer animation.
|
|
85
|
+
- `autoMeasurerPlugin` drops an element's previous index when it is observed for a new one, so an element reused for another row is no longer measured under its stale index.
|
|
86
|
+
- `useLoadMoreWhenShort` handles a rejected `onLoadMore()` (logged as `[Scrollex] Error in onLoadMore:`) instead of leaving an unhandled rejection.
|
|
87
|
+
|
|
10
88
|
## [1.0.0] - 2025-12-27
|
|
11
89
|
|
|
12
90
|
### Added
|
|
@@ -39,13 +117,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
39
117
|
- `scrollControllerPlugin` - Programmatic scroll control with easing functions
|
|
40
118
|
|
|
41
119
|
#### Optional Plugins
|
|
42
|
-
- `
|
|
120
|
+
- `debugPanel` - Visual debugging panel with FPS, render count, and memory stats
|
|
43
121
|
|
|
44
122
|
#### Performance Features
|
|
45
123
|
- Zero runtime dependencies (React is peer dependency only)
|
|
46
|
-
- Tree-shakeable exports for minimal bundle size (~
|
|
124
|
+
- Tree-shakeable exports for minimal bundle size (~5KB core)
|
|
47
125
|
- Measurement caching for variable heights
|
|
48
|
-
- Object pooling to minimize garbage collection
|
|
49
126
|
- CSS containment support for rendering optimization
|
|
50
127
|
- Overscan configuration for smooth scrolling
|
|
51
128
|
|
|
@@ -60,9 +137,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
60
137
|
- Tested with 100,000+ items at consistent 60fps
|
|
61
138
|
- Supports React 17.0.0 and above
|
|
62
139
|
- Node.js 18.0.0+ required for development
|
|
63
|
-
- Modern browser support (Chrome 80+, Firefox 75+, Safari 13+, Edge 80+)
|
|
140
|
+
- Modern browser support (Chrome 80+, Firefox 75+, Safari 13.1+, Edge 80+)
|
|
64
141
|
|
|
65
142
|
---
|
|
66
143
|
|
|
67
|
-
[Unreleased]: https://github.com/ersinkoc/Scrollex/compare/v1.
|
|
144
|
+
[Unreleased]: https://github.com/ersinkoc/Scrollex/compare/v1.1.0...HEAD
|
|
145
|
+
[1.1.0]: https://github.com/ersinkoc/Scrollex/compare/v1.0.3...v1.1.0
|
|
146
|
+
[1.0.3]: https://github.com/ersinkoc/Scrollex/compare/v1.0.2...v1.0.3
|
|
147
|
+
[1.0.2]: https://github.com/ersinkoc/Scrollex/compare/v1.0.1...v1.0.2
|
|
148
|
+
[1.0.1]: https://github.com/ersinkoc/Scrollex/compare/v1.0.0...v1.0.1
|
|
68
149
|
[1.0.0]: https://github.com/ersinkoc/Scrollex/releases/tag/v1.0.0
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
- **Zero Dependencies** - No runtime dependencies, React is a peer dependency
|
|
21
21
|
- **High Performance** - 100k+ items at 60fps with RAF-based rendering
|
|
22
|
-
- **Micro-Kernel Architecture** - Small core (~
|
|
22
|
+
- **Micro-Kernel Architecture** - Small core (~5KB) with tree-shakeable plugins
|
|
23
23
|
- **Variable Heights** - Auto-measurement for dynamic content
|
|
24
24
|
- **Infinite Scroll** - Built-in bidirectional infinite loading
|
|
25
25
|
- **Multiple Layouts** - List, Grid, and Masonry components
|
|
@@ -191,25 +191,31 @@ Extend functionality with optional plugins:
|
|
|
191
191
|
|
|
192
192
|
```tsx
|
|
193
193
|
import { VirtualList } from '@oxog/scrollex'
|
|
194
|
-
import { infiniteLoaderPlugin,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
194
|
+
import { infiniteLoaderPlugin, debugPanel, DebugPanelOverlay } from '@oxog/scrollex/plugins'
|
|
195
|
+
|
|
196
|
+
// Create the debug panel once (outside render or in useMemo): the overlay reads its state
|
|
197
|
+
const debug = debugPanel({ position: 'bottom-right' })
|
|
198
|
+
|
|
199
|
+
<>
|
|
200
|
+
<VirtualList
|
|
201
|
+
data={items}
|
|
202
|
+
itemHeight={50}
|
|
203
|
+
plugins={[
|
|
204
|
+
infiniteLoaderPlugin({
|
|
205
|
+
threshold: 200,
|
|
206
|
+
onLoadMore: async (direction) => {
|
|
207
|
+
const newItems = await fetchMore(direction)
|
|
208
|
+
setItems(prev => [...prev, ...newItems])
|
|
209
|
+
}
|
|
210
|
+
}),
|
|
211
|
+
debug,
|
|
212
|
+
]}
|
|
213
|
+
renderItem={({ item, style }) => (
|
|
214
|
+
<div style={style}>{item.name}</div>
|
|
215
|
+
)}
|
|
216
|
+
/>
|
|
217
|
+
<DebugPanelOverlay plugin={debug} />
|
|
218
|
+
</>
|
|
213
219
|
```
|
|
214
220
|
|
|
215
221
|
### Available Plugins
|
|
@@ -221,7 +227,9 @@ import { infiniteLoaderPlugin, debugPanelPlugin } from '@oxog/scrollex/plugins'
|
|
|
221
227
|
| `autoMeasurerPlugin` | Automatic height measurement |
|
|
222
228
|
| `infiniteLoaderPlugin` | Infinite scroll loading |
|
|
223
229
|
| `scrollControllerPlugin` | Programmatic scroll control |
|
|
224
|
-
| `
|
|
230
|
+
| `debugPanel` + `DebugPanelOverlay` | Visual debugging tools |
|
|
231
|
+
|
|
232
|
+
`VirtualList`, `VirtualGrid` and their hooks already register `listRendererPlugin` / `gridRendererPlugin` themselves: passing one in `plugins` throws "already registered". Use them directly only with a kernel.
|
|
225
233
|
|
|
226
234
|
## Infinite Scroll
|
|
227
235
|
|
|
@@ -283,7 +291,7 @@ Tested with **100,000+ items** at consistent 60fps.
|
|
|
283
291
|
|
|
284
292
|
- Chrome 80+
|
|
285
293
|
- Firefox 75+
|
|
286
|
-
- Safari 13+
|
|
294
|
+
- Safari 13.1+
|
|
287
295
|
- Edge 80+
|
|
288
296
|
|
|
289
297
|
## Documentation
|