vlist 1.6.0 → 1.6.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.
@@ -13,11 +13,56 @@
13
13
  * - Uses window.innerWidth/innerHeight for container dimensions
14
14
  * - Listens to window resize events instead of ResizeObserver
15
15
  * - Adjusts DOM styles (overflow: visible, height: auto)
16
+ * - Optionally accounts for fixed/sticky chrome via scrollPadding
17
+ * - Uses behavior: "instant" on all scrollTo calls to override CSS
18
+ * scroll-behavior: smooth that may be set on the page
16
19
  *
17
20
  * Bundle impact: ~0.3 KB gzipped when used
18
21
  */
19
22
  import type { VListItem } from "../../types";
20
23
  import type { VListFeature } from "../../builder/types";
24
+ /**
25
+ * Options for the window scroll mode feature.
26
+ */
27
+ export interface WithPageOptions {
28
+ /**
29
+ * Scroll padding — insets from the viewport edges where fixed/sticky
30
+ * elements (headers, footers, toolbars) live.
31
+ *
32
+ * When keyboard focus moves an item behind a sticky bar, the list
33
+ * auto-scrolls to keep it within the visible (unobstructed) area.
34
+ * Also affects `scrollToIndex` alignment (start/center/end).
35
+ *
36
+ * Mirrors CSS `scroll-padding` semantics: defines the optimal viewing
37
+ * region within the scrollport.
38
+ *
39
+ * Values can be numbers (pixels) or functions that return pixels
40
+ * (useful when the sticky element's height is dynamic).
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * withPage({
45
+ * scrollPadding: { top: 60, bottom: 50 }
46
+ * })
47
+ * ```
48
+ *
49
+ * @example Dynamic values
50
+ * ```ts
51
+ * withPage({
52
+ * scrollPadding: {
53
+ * top: () => document.getElementById('sticky-header')!.offsetHeight,
54
+ * bottom: 50
55
+ * }
56
+ * })
57
+ * ```
58
+ */
59
+ scrollPadding?: {
60
+ top?: number | (() => number);
61
+ bottom?: number | (() => number);
62
+ left?: number | (() => number);
63
+ right?: number | (() => number);
64
+ };
65
+ }
21
66
  /**
22
67
  * Create a window scroll mode feature.
23
68
  *
@@ -38,6 +83,17 @@ import type { VListFeature } from "../../builder/types";
38
83
  * .build()
39
84
  * ```
40
85
  *
86
+ * @example With scroll padding for sticky chrome
87
+ * ```ts
88
+ * const feed = vlist({
89
+ * container: '#infinite-feed',
90
+ * item: { height: 200, template: renderPost },
91
+ * items: posts
92
+ * })
93
+ * .use(withPage({ scrollPadding: { top: 60, bottom: 50 } }))
94
+ * .build()
95
+ * ```
96
+ *
41
97
  * @example Horizontal window scrolling
42
98
  * ```ts
43
99
  * const timeline = vlist({
@@ -49,5 +105,5 @@ import type { VListFeature } from "../../builder/types";
49
105
  * .build()
50
106
  * ```
51
107
  */
52
- export declare const withPage: <T extends VListItem = VListItem>() => VListFeature<T>;
108
+ export declare const withPage: <T extends VListItem = VListItem>(options?: WithPageOptions) => VListFeature<T>;
53
109
  //# sourceMappingURL=feature.d.ts.map
@@ -4,5 +4,6 @@
4
4
  * Entry point for the window scroll feature.
5
5
  */
6
6
  export { withPage } from "./feature";
7
+ export type { WithPageOptions } from "./feature";
7
8
  export type { VListFeature } from "../../builder/types";
8
9
  //# sourceMappingURL=index.d.ts.map
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export type { ScaleConfig } from "./features/scale";
14
14
  export { withAsync } from "./features/async";
15
15
  export { withScrollbar } from "./features/scrollbar";
16
16
  export { withPage } from "./features/page";
17
+ export type { WithPageOptions } from "./features/page";
17
18
  export { withGroups } from "./features/groups";
18
19
  export { withGrid } from "./features/grid";
19
20
  export { withMasonry } from "./features/masonry";