compute-scroll-into-view 2.0.0 → 2.0.1
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/README.md +13 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,13 +22,13 @@ Scrolling SVG elements are supported, as well as Shadow DOM elements. The [Visua
|
|
|
22
22
|
- [boundary](#boundary)
|
|
23
23
|
- [skipOverflowHiddenElements](#skipoverflowhiddenelements)
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
# Install
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
28
|
npm i compute-scroll-into-view
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
You can also use it from
|
|
31
|
+
You can also use it from a CDN:
|
|
32
32
|
|
|
33
33
|
```js
|
|
34
34
|
const { default: compute } = await import(
|
|
@@ -36,7 +36,7 @@ const { default: compute } = await import(
|
|
|
36
36
|
)
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
# Usage
|
|
40
40
|
|
|
41
41
|
```js
|
|
42
42
|
import compute from 'compute-scroll-into-view'
|
|
@@ -66,28 +66,28 @@ actions.forEach(({ el, top, left }) => {
|
|
|
66
66
|
})
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
# API
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
## compute(target, options)
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
## options
|
|
74
74
|
|
|
75
75
|
Type: `Object`
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
### [block](https://scroll-into-view.dev/#scroll-alignment)
|
|
78
78
|
|
|
79
79
|
Type: `'start' | 'center' | 'end' | 'nearest'`<br> Default: `'center'`
|
|
80
80
|
|
|
81
81
|
Control the logical scroll position on the y-axis. The spec states that the `block` direction is related to the [writing-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode), but this is not implemented yet in this library.
|
|
82
82
|
This means that `block: 'start'` aligns to the top edge and `block: 'end'` to the bottom.
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
### [inline](https://scroll-into-view.dev/#scroll-alignment)
|
|
85
85
|
|
|
86
86
|
Type: `'start' | 'center' | 'end' | 'nearest'`<br> Default: `'nearest'`
|
|
87
87
|
|
|
88
88
|
Like `block` this is affected by the [writing-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode). In left-to-right pages `inline: 'start'` will align to the left edge. In right-to-left it should be flipped. This will be supported in a future release.
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
### [scrollMode](https://scroll-into-view.dev/#scrolling-if-needed)
|
|
91
91
|
|
|
92
92
|
Type: `'always' | 'if-needed'`<br> Default: `'always'`
|
|
93
93
|
|
|
@@ -96,7 +96,7 @@ This is a proposed addition to the spec that you can track here: https://github.
|
|
|
96
96
|
This library will be updated to reflect any changes to the spec and will provide a migration path.
|
|
97
97
|
To be backwards compatible with `Element.scrollIntoViewIfNeeded` if something is not 100% visible it will count as "needs scrolling". If you need a different visibility ratio your best option would be to implement an [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
### [boundary](https://scroll-into-view.dev/#limit-propagation)
|
|
100
100
|
|
|
101
101
|
Type: `Element | Function`
|
|
102
102
|
|
|
@@ -122,7 +122,7 @@ const actions = compute(target, {
|
|
|
122
122
|
})
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
### skipOverflowHiddenElements
|
|
126
126
|
|
|
127
127
|
Type: `Boolean`<br> Default: `false`
|
|
128
128
|
|
|
@@ -130,6 +130,6 @@ By default the [spec](https://drafts.csswg.org/cssom-view/#scrolling-box) states
|
|
|
130
130
|
|
|
131
131
|
This package follows the convention [adopted by Firefox](https://hg.mozilla.org/integration/fx-team/rev/c48c3ec05012#l7.18) of setting a boolean option to _not_ scroll all nodes with `overflow: hidden` set.
|
|
132
132
|
|
|
133
|
-
[gzip-badge]: https://img.
|
|
134
|
-
[size-badge]: https://img.
|
|
133
|
+
[gzip-badge]: https://img.shields.io/bundlephobia/minzip/compute-scroll-into-view?label=gzip%20size&style=flat-square
|
|
134
|
+
[size-badge]: https://img.shields.io/bundlephobia/min/compute-scroll-into-view?label=size&style=flat-square
|
|
135
135
|
[unpkg-dist]: https://unpkg.com/compute-scroll-into-view/dist/
|