@tb-dev/prototype-dom 6.2.0 → 6.3.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/dist/index.d.ts +9 -6
- package/dist/index.iife.js +12 -8
- package/package.json +12 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
export declare interface ScrollAsyncOptions extends ScrollIntoViewOptions {
|
|
2
|
+
timeout?: number;
|
|
3
|
+
/** @default true */
|
|
4
|
+
throwOnTimeout?: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
export { }
|
|
2
8
|
|
|
9
|
+
|
|
3
10
|
declare global {
|
|
4
11
|
interface Document {
|
|
5
12
|
/**
|
|
@@ -42,9 +49,7 @@ declare global {
|
|
|
42
49
|
* @param selector CSS selector to match.
|
|
43
50
|
* @param options Options to customize the scrolling behavior.
|
|
44
51
|
*/
|
|
45
|
-
scrollAsync: (selector: string, options?:
|
|
46
|
-
timeout?: number;
|
|
47
|
-
} & ScrollIntoViewOptions) => Promise<void>;
|
|
52
|
+
scrollAsync: (selector: string, options?: ScrollAsyncOptions) => Promise<void>;
|
|
48
53
|
/**
|
|
49
54
|
* Wait for the first descendant element that matches the given selector to exist.
|
|
50
55
|
* @param selector CSS selector to match.
|
|
@@ -140,9 +145,7 @@ declare global {
|
|
|
140
145
|
* @param selector CSS selector to match.
|
|
141
146
|
* @param options Options to customize the scrolling behavior.
|
|
142
147
|
*/
|
|
143
|
-
scrollAsync: (selector: string, options?:
|
|
144
|
-
timeout?: number;
|
|
145
|
-
} & ScrollIntoViewOptions) => Promise<void>;
|
|
148
|
+
scrollAsync: (selector: string, options?: ScrollAsyncOptions) => Promise<void>;
|
|
146
149
|
/**
|
|
147
150
|
* Wait for the first descendant element that matches the given selector to exist.
|
|
148
151
|
* @param selector CSS selector to match.
|
package/dist/index.iife.js
CHANGED
|
@@ -115,14 +115,18 @@
|
|
|
115
115
|
}
|
|
116
116
|
function scrollAsync() {
|
|
117
117
|
return async function(selector, options = {}) {
|
|
118
|
-
const { timeout, ...scrollOptions } = options;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
118
|
+
const { timeout, throwOnTimeout = true, ...scrollOptions } = options;
|
|
119
|
+
try {
|
|
120
|
+
const element2 = await this.waitChild(selector, timeout);
|
|
121
|
+
element2.scrollIntoView({
|
|
122
|
+
behavior: "smooth",
|
|
123
|
+
block: "center",
|
|
124
|
+
inline: "nearest",
|
|
125
|
+
...scrollOptions
|
|
126
|
+
});
|
|
127
|
+
} catch (err) {
|
|
128
|
+
if (throwOnTimeout) throw err;
|
|
129
|
+
}
|
|
126
130
|
};
|
|
127
131
|
}
|
|
128
132
|
const element = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tb-dev/prototype-dom",
|
|
3
|
-
"version": "6.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "6.3.1",
|
|
4
|
+
"description": "Prototype methods for DOM objects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": {
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"*.{?(c|m)@(j|t)s,css,vue,md,json}": "prettier --write"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@tb-dev/eslint-config": "^5.
|
|
26
|
-
"eslint": "^9.
|
|
27
|
-
"husky": "^9.1.
|
|
28
|
-
"lint-staged": "^15.2.
|
|
25
|
+
"@tb-dev/eslint-config": "^5.3.3",
|
|
26
|
+
"eslint": "^9.11.1",
|
|
27
|
+
"husky": "^9.1.6",
|
|
28
|
+
"lint-staged": "^15.2.10",
|
|
29
29
|
"prettier": "^3.3.3",
|
|
30
|
-
"tslib": "^2.
|
|
31
|
-
"typedoc": "^0.26.
|
|
32
|
-
"typedoc-plugin-mdn-links": "^3.2
|
|
33
|
-
"typescript": "^5.
|
|
34
|
-
"vite": "^5.4.
|
|
35
|
-
"vite-plugin-dts": "^4.
|
|
30
|
+
"tslib": "^2.7.0",
|
|
31
|
+
"typedoc": "^0.26.7",
|
|
32
|
+
"typedoc-plugin-mdn-links": "^3.3.2",
|
|
33
|
+
"typescript": "^5.6.2",
|
|
34
|
+
"vite": "^5.4.8",
|
|
35
|
+
"vite-plugin-dts": "^4.2.3"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"dist/**/*"
|