@vdegenne/highlight-manager 0.1.9 → 0.1.10
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/lib/index.d.ts +8 -2
- package/lib/index.js +4 -3
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -20,9 +20,13 @@ interface ScrollStrategy {
|
|
|
20
20
|
*/
|
|
21
21
|
behavior: ScrollBehavior;
|
|
22
22
|
/**
|
|
23
|
-
* @default
|
|
23
|
+
* @default undefined
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
block: ScrollLogicalPosition | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* @default undefined
|
|
28
|
+
*/
|
|
29
|
+
inline: ScrollLogicalPosition | undefined;
|
|
26
30
|
}
|
|
27
31
|
interface Options {
|
|
28
32
|
css: string;
|
|
@@ -47,6 +51,8 @@ interface Options {
|
|
|
47
51
|
*/
|
|
48
52
|
applyStyleSheetTo: Document | HTMLElement | ShadowRoot;
|
|
49
53
|
/**
|
|
54
|
+
* Set to at least `{}` to activate scrolling when offscreen
|
|
55
|
+
*
|
|
50
56
|
* @default undefined
|
|
51
57
|
*/
|
|
52
58
|
scrollStrategy: Partial<ScrollStrategy> | undefined;
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,8 @@ import { isInViewport, sleep } from './utils.js';
|
|
|
3
3
|
const scrollStrategyDefaults = {
|
|
4
4
|
whenWhatPartIsHidden: 'center',
|
|
5
5
|
behavior: 'smooth',
|
|
6
|
-
|
|
6
|
+
block: undefined,
|
|
7
|
+
inline: undefined,
|
|
7
8
|
};
|
|
8
9
|
const defaults = {
|
|
9
10
|
atomicSelection(_element) {
|
|
@@ -194,8 +195,8 @@ export class HighLightManager {
|
|
|
194
195
|
!isInViewport(elementsToHighlight[0], _options.scrollStrategy.whenWhatPartIsHidden)) {
|
|
195
196
|
elementsToHighlight[0]?.scrollIntoView({
|
|
196
197
|
behavior: _options.scrollStrategy.behavior,
|
|
197
|
-
block: _options.scrollStrategy.
|
|
198
|
-
inline: _options.scrollStrategy.
|
|
198
|
+
block: _options.scrollStrategy.block,
|
|
199
|
+
inline: _options.scrollStrategy.block,
|
|
199
200
|
});
|
|
200
201
|
}
|
|
201
202
|
elementsToHighlight.forEach((el) => el.setAttribute(`highlight${this.#id}`, ''));
|