@medyll/idae-dom-events 0.5.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 +251 -0
- package/dist/components/content.html +44 -0
- package/dist/cssDom.d.ts +190 -0
- package/dist/cssDom.js +456 -0
- package/dist/htmlDom.d.ts +73 -0
- package/dist/htmlDom.js +291 -0
- package/dist/htmluModules.d.ts +27 -0
- package/dist/htmluModules.js +122 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/moduleLib/index.d.ts +11 -0
- package/dist/moduleLib/index.js +10 -0
- package/dist/moduleLib/resizePanel.d.ts +6 -0
- package/dist/moduleLib/resizePanel.js +93 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
|
|
2
|
+
# dom-events Library
|
|
3
|
+
|
|
4
|
+
dom-events is a powerful library for observing and reacting to DOM changes in web applications. It provides two main classes: cssDom and htmlDom.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @medyll/idae-dom-events
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
import { cssDom, htmlDom } from "@medyll/idae-dom-events";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## CssObserver
|
|
19
|
+
|
|
20
|
+
CssObserver allows you to track CSS changes and animations on specified elements to trigger custom actions or updates.
|
|
21
|
+
|
|
22
|
+
### Key Features:
|
|
23
|
+
- Track new elements matching a selector
|
|
24
|
+
- Observe attribute changes
|
|
25
|
+
- Monitor child list modifications
|
|
26
|
+
- Track element resizing
|
|
27
|
+
|
|
28
|
+
### Basic Usage:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
cssDom('#myElement').each((element) => {
|
|
32
|
+
console.log('Element changed:', element);
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Advanced Usage:
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
cssDom('#myElement', {
|
|
40
|
+
onlyNew: true,
|
|
41
|
+
trackChildList: true,
|
|
42
|
+
trackAttributes: ['class', 'style'],
|
|
43
|
+
trackResize: true
|
|
44
|
+
}).each((element) => {
|
|
45
|
+
console.log('Element updated:', element);
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## HtmluDomLib (htmlDom)
|
|
50
|
+
|
|
51
|
+
HtmluDomLib provides a more detailed way to observe DOM mutations.
|
|
52
|
+
|
|
53
|
+
### Key Features:
|
|
54
|
+
- Singleton instance for global use
|
|
55
|
+
- Flexible mutation tracking
|
|
56
|
+
- Support for multiple selectors and mutation types
|
|
57
|
+
|
|
58
|
+
### Basic Usage:
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
htmlDom.track('#myElement', ['class'], {
|
|
62
|
+
onAttributesChange: (element, mutation, observer) => {
|
|
63
|
+
console.log('Attribute changed:', mutation);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Advanced Usage:
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
htmlDom.attach({
|
|
72
|
+
selectors: [{ element: '#myElement', mutations: { attributes: ['class'] } }],
|
|
73
|
+
selectorCallback: (mutations, observer) => ({
|
|
74
|
+
attributes: (mutation, observer) => {
|
|
75
|
+
console.log('Attribute mutation:', mutation);
|
|
76
|
+
},
|
|
77
|
+
childList: (mutation, observer) => {
|
|
78
|
+
console.log('Child list mutation:', mutation);
|
|
79
|
+
}
|
|
80
|
+
}),
|
|
81
|
+
observerParameters: {
|
|
82
|
+
subtree: true,
|
|
83
|
+
childList: true
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Detailed Usage Guide
|
|
89
|
+
|
|
90
|
+
### CssObserver (cssDom)
|
|
91
|
+
|
|
92
|
+
The CssObserver class, accessed via the `cssDom` function, provides a powerful way to track CSS changes and animations on specified elements.
|
|
93
|
+
|
|
94
|
+
#### Basic Usage:
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
import { cssDom } from "@medyll/htmludom";
|
|
98
|
+
|
|
99
|
+
cssDom('#myElement').each((element) => {
|
|
100
|
+
console.log('Element changed:', element);
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Advanced Features:
|
|
105
|
+
|
|
106
|
+
1. **Track Only New Elements:**
|
|
107
|
+
```javascript
|
|
108
|
+
cssDom('#myElement', { onlyNew: true }).each((element , changes) => {
|
|
109
|
+
console.log('New element added:', element);
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
2. **Observe Child List Changes:**
|
|
114
|
+
```javascript
|
|
115
|
+
cssDom('#myElement', { trackChildList: true }).each((element , changes) => {
|
|
116
|
+
console.log('Child list changed for:', element);
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
3. **Monitor Specific Attributes:**
|
|
121
|
+
```javascript
|
|
122
|
+
cssDom('#myElement', { trackAttributes: ['class', 'style'] }).each((element , changes) => {
|
|
123
|
+
console.log('Tracked attribute changed for:', element);
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
4. **Track Resize Events:**
|
|
128
|
+
```javascript
|
|
129
|
+
cssDom('#myElement', { trackResize: true }).each((element , changes) => {
|
|
130
|
+
console.log('Element resized:', element);
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
5. **Get Summary of Changes:**
|
|
135
|
+
```javascript
|
|
136
|
+
cssDom('#myElement').summary((changedElements) => {
|
|
137
|
+
console.log('Elements changed:', changedElements);
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
#### Basic Usage:
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
import { htmlDom } from "@medyll/htmludom";
|
|
146
|
+
|
|
147
|
+
htmlDom.track('#myElement', ['class'], {
|
|
148
|
+
onAttributesChange: (element, mutation, observer) => {
|
|
149
|
+
console.log('Class attribute changed:', element, mutation);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### Advanced Features:
|
|
155
|
+
|
|
156
|
+
1. **Observe Multiple Mutation Types:**
|
|
157
|
+
```javascript
|
|
158
|
+
htmlDom.track('#myElement', {
|
|
159
|
+
onAttributesChange: (element, mutation, observer) => {
|
|
160
|
+
console.log('Attribute changed:', mutation.attributeName);
|
|
161
|
+
},
|
|
162
|
+
onChildListChange: (element, mutation, observer) => {
|
|
163
|
+
console.log('Child nodes changed');
|
|
164
|
+
},
|
|
165
|
+
onCharacterDataChange: (element, mutation, observer) => {
|
|
166
|
+
console.log('Text content changed');
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
2. **Use Complex Selectors:**
|
|
172
|
+
```javascript
|
|
173
|
+
htmlDom.track(['#myElement', '.myClass'], ['style', 'class'], {
|
|
174
|
+
onAttributesChange: (element, mutation, observer) => {
|
|
175
|
+
console.log('Style or class changed for:', element);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
3. **Attach Multiple Observers:**
|
|
181
|
+
```javascript
|
|
182
|
+
htmlDom.attach([
|
|
183
|
+
{
|
|
184
|
+
selectors: [{ element: '#element1', mutations: { attributes: ['class'] } }],
|
|
185
|
+
selectorCallback: (mutations, observer) => ({
|
|
186
|
+
attributes: (mutation, observer) => console.log('Class changed for element1')
|
|
187
|
+
}),
|
|
188
|
+
observerParameters: { subtree: true }
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
selectors: [{ element: '#element2', mutations: { childList: true } }],
|
|
192
|
+
selectorCallback: (mutations, observer) => ({
|
|
193
|
+
childList: (mutation, observer) => console.log('Children changed for element2')
|
|
194
|
+
}),
|
|
195
|
+
observerParameters: { childList: true }
|
|
196
|
+
}
|
|
197
|
+
]);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
4. **Detach Observers:**
|
|
201
|
+
```javascript
|
|
202
|
+
// Detach all observers
|
|
203
|
+
htmlDom.detach();
|
|
204
|
+
|
|
205
|
+
// Detach observer for specific selector
|
|
206
|
+
htmlDom.detach('#myElement');
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### The why and how of using cssEvents and domChange together in web applications.
|
|
210
|
+
|
|
211
|
+
Using cssEvents and domChange offers a balanced approach to tracking DOM changes and CSS-related events in web applications. This combination provides several advantages:
|
|
212
|
+
|
|
213
|
+
1. Efficiency: cssEvents leverages CSS animations to detect new elements, which is more performant than constantly querying the DOM.
|
|
214
|
+
|
|
215
|
+
2. Flexibility: domChange uses MutationObserver, allowing for precise tracking of various DOM mutations, including attribute changes and child node modifications.
|
|
216
|
+
|
|
217
|
+
3. Comprehensive coverage: Together, these methods can capture a wide range of changes, from style updates to structural DOM alterations.
|
|
218
|
+
|
|
219
|
+
4. Browser compatibility: This approach works well across modern browsers, providing a consistent experience.
|
|
220
|
+
|
|
221
|
+
5. Reduced overhead: By focusing on specific changes, you can minimize unnecessary processing and improve overall application performance.
|
|
222
|
+
|
|
223
|
+
6. Ease of use: The API for both methods is designed to be developer-friendly, making it simple to implement and maintain.
|
|
224
|
+
|
|
225
|
+
7. Scalability: This solution is suitable for both small projects and large-scale applications, adapting well to different complexity levels.
|
|
226
|
+
By combining cssEvents for style-related changes and domChange for structural modifications, developers can create responsive, efficient, and robust web applications that react seamlessly to various types of DOM and CSS updates.
|
|
227
|
+
|
|
228
|
+
8. Resume
|
|
229
|
+
dom-events is a TypeScript library designed to simplify the use of the MutationObserver API, making manipulation of the Document Object Model (DOM) more intuitive and suitable for different use cases. This library is particularly useful for web applications that require dynamic DOM management, such as tracking attribute changes, observing changes in the child list of an element, and detecting character data changes.
|
|
230
|
+
|
|
231
|
+
The versatility of dom-events allows it to be used in a wide range of web applications, from simple to complex. It is ideal for situations where dynamic DOM monitoring is required, such as tracking attribute changes, observing changes in the child list of an element, or detecting character data changes.
|
|
232
|
+
### Performance Considerations
|
|
233
|
+
|
|
234
|
+
- Use specific selectors when possible to limit the scope of observation.
|
|
235
|
+
- When tracking attributes, specify only the attributes you need to observe.
|
|
236
|
+
- For frequently changing elements, consider using debounce techniques in your callback functions.
|
|
237
|
+
- Detach observers when they are no longer needed to free up resources.
|
|
238
|
+
|
|
239
|
+
### Browser Compatibility
|
|
240
|
+
|
|
241
|
+
dom-events uses modern browser features such as MutationObserver and ResizeObserver. Ensure your target browsers support these APIs. For older browsers, consider using polyfills or fallback mechanisms.
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
## Browser Compatibility
|
|
245
|
+
|
|
246
|
+
dom-events uses modern browser features.
|
|
247
|
+
Ensure your target browsers support MutationObserver and other required APIs.
|
|
248
|
+
|
|
249
|
+
## License
|
|
250
|
+
|
|
251
|
+
[MIT License](LICENSE)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
const id = 'aaa';
|
|
3
|
+
const red = new ResizeObserver((entries) => {
|
|
4
|
+
for (let entry of entries) {
|
|
5
|
+
console.log('Element:', entry.target);
|
|
6
|
+
console.log('Width:', entry.contentRect.width);
|
|
7
|
+
console.log('Height:', entry.contentRect.height);
|
|
8
|
+
console.log('Box:', entry.contentRect);
|
|
9
|
+
console.log('Padding:', entry.contentRect.padding);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
red.observe(element);
|
|
13
|
+
|
|
14
|
+
let data;
|
|
15
|
+
data.onchange = () => console.log(element);
|
|
16
|
+
</script>
|
|
17
|
+
<content id="{id}">
|
|
18
|
+
<bind from="company.name"></bind>
|
|
19
|
+
<nav>
|
|
20
|
+
<loop
|
|
21
|
+
data-url="api/users"
|
|
22
|
+
collection="users"
|
|
23
|
+
filter="where:user.name=*jean*"
|
|
24
|
+
sort="name"
|
|
25
|
+
groupBy="field"
|
|
26
|
+
toggle=""
|
|
27
|
+
>
|
|
28
|
+
<h2 slot="title">title once</h2>
|
|
29
|
+
<div mdl="component/li-item" collection="users" data="" data-id="">inner content</div>
|
|
30
|
+
<be-item component>inner content</be-item>
|
|
31
|
+
</loop>
|
|
32
|
+
</nav>
|
|
33
|
+
<if>
|
|
34
|
+
<elseif>
|
|
35
|
+
<div>cond 1</div>
|
|
36
|
+
</elseif>
|
|
37
|
+
<else> cond 2 </else>
|
|
38
|
+
</if>
|
|
39
|
+
<slot> </slot>
|
|
40
|
+
</content>
|
|
41
|
+
<style>
|
|
42
|
+
#id {
|
|
43
|
+
}
|
|
44
|
+
</style>
|
package/dist/cssDom.d.ts
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
export type CssObserverCommands = {
|
|
2
|
+
start: () => void;
|
|
3
|
+
pause: () => void;
|
|
4
|
+
destroy: () => void;
|
|
5
|
+
};
|
|
6
|
+
export type CssObserverCallBack = undefined | ((node: Node, mutation?: MutationRecord) => void);
|
|
7
|
+
export type CssObserverCallBackSummary = (nodes: Node[]) => void;
|
|
8
|
+
export type CssObserverOptions = {
|
|
9
|
+
strictlyNew: boolean;
|
|
10
|
+
eventDelay: number;
|
|
11
|
+
marquee: string;
|
|
12
|
+
legacyCssPrefix: 'Webkit' | 'Moz' | 'O' | 'ms' | '';
|
|
13
|
+
debounceDelay: number;
|
|
14
|
+
};
|
|
15
|
+
/** QuerySelector */
|
|
16
|
+
type QuerySelector = string;
|
|
17
|
+
/**
|
|
18
|
+
* CssObserver class for tracking CSS changes and animations.
|
|
19
|
+
*/
|
|
20
|
+
export declare class CssObserver {
|
|
21
|
+
private selector;
|
|
22
|
+
private selectorId;
|
|
23
|
+
private activeAnimations;
|
|
24
|
+
private resizeObserver;
|
|
25
|
+
private loadedSelectors;
|
|
26
|
+
/**
|
|
27
|
+
* Default options for the CssObserver.
|
|
28
|
+
*/
|
|
29
|
+
options: CssObserverOptions;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new instance of CssObserver.
|
|
32
|
+
* @param {QuerySelector} selector - The query selector for the instance.
|
|
33
|
+
*/
|
|
34
|
+
constructor(selector?: QuerySelector);
|
|
35
|
+
setSelector(selector: QuerySelector): void;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if the browser supports necessary features.
|
|
38
|
+
* @throws {Error} If the browser doesn't support required features.
|
|
39
|
+
*/
|
|
40
|
+
private static checkBrowserSupport;
|
|
41
|
+
/**
|
|
42
|
+
* Removes special characters from a string.
|
|
43
|
+
* @param {string} str - The string to clean.
|
|
44
|
+
* @returns {string} The cleaned string.
|
|
45
|
+
*/
|
|
46
|
+
private cleanSpecialChars;
|
|
47
|
+
/**
|
|
48
|
+
* Tracks animation events for the specified selector and invokes the callback function.
|
|
49
|
+
* @param {CssObserverCallBack} callback - The callback function to be invoked.
|
|
50
|
+
* @param {Object} opts - Optional settings.
|
|
51
|
+
* @param {boolean} [opts.onlyNew=false] - Whether to track only new elements.
|
|
52
|
+
* @param {boolean} [opts.trackChildList] - Whether to track child list changes.
|
|
53
|
+
* @param {boolean|string[]} [opts.trackAttributes] - Whether to track attribute changes or an array of specific attributes.
|
|
54
|
+
* @param {boolean} [opts.trackResize] - Whether to track resize events.
|
|
55
|
+
* @returns {Object} An object with methods to control the animation tracking.
|
|
56
|
+
*/
|
|
57
|
+
track(callback: CssObserverCallBack, opts?: {
|
|
58
|
+
animationName?: string;
|
|
59
|
+
onlyNew?: boolean;
|
|
60
|
+
trackChildList?: boolean;
|
|
61
|
+
trackAttributes?: string[];
|
|
62
|
+
trackCharacterData?: boolean;
|
|
63
|
+
trackResize?: boolean;
|
|
64
|
+
}): CssObserverCommands;
|
|
65
|
+
/**
|
|
66
|
+
* Processes existing elements that match the selector.
|
|
67
|
+
* @param {CssObserverCallBack} callback - The callback function to be invoked for each element.
|
|
68
|
+
*/
|
|
69
|
+
private processExistingElements;
|
|
70
|
+
/**
|
|
71
|
+
* Creates an event handler for animation events.
|
|
72
|
+
* @param {string} animationName - The name of the animation to track.
|
|
73
|
+
* @param {CssObserverCallBack} callback - The callback function to be invoked.
|
|
74
|
+
* @returns {Function} The event handler function.
|
|
75
|
+
*/
|
|
76
|
+
private createEventHandler;
|
|
77
|
+
/**
|
|
78
|
+
* Calls the callback function for an element if it hasn't been processed before.
|
|
79
|
+
* @param {Element} element - The element to process.
|
|
80
|
+
* @param {CssObserverCallBack} callback - The callback function to be invoked.
|
|
81
|
+
* @param {MutationRecord} [mutation] - The mutation record associated with the change.
|
|
82
|
+
*/
|
|
83
|
+
private callCallback;
|
|
84
|
+
/**
|
|
85
|
+
* Gets a summary of changes by grouping them under parent elements.
|
|
86
|
+
* @param {CssObserverCallBackSummary} callback - The callback function to be invoked with the summary.
|
|
87
|
+
* @param {Object} opts - Optional settings.
|
|
88
|
+
* @param {boolean} [opts.onlyNew=false] - Whether to track only new elements.
|
|
89
|
+
* @param {boolean} [opts.trackChildList] - Whether to track child list changes.
|
|
90
|
+
* @param {boolean|string[]} [opts.trackAttributes] - Whether to track attribute changes or an array of specific attributes.
|
|
91
|
+
* @param {boolean} [opts.trackResize] - Whether to track resize events.
|
|
92
|
+
* @returns {Object} An object with methods to control the summary tracking.
|
|
93
|
+
*/
|
|
94
|
+
getSummary(callback: CssObserverCallBackSummary, opts?: {
|
|
95
|
+
onlyNew?: boolean;
|
|
96
|
+
trackChildList?: boolean;
|
|
97
|
+
trackAttributes?: boolean | string[];
|
|
98
|
+
trackResize?: boolean;
|
|
99
|
+
}): CssObserverCommands;
|
|
100
|
+
/**
|
|
101
|
+
* Sets options for the CssObserver instance.
|
|
102
|
+
* @param {CssObserverOptions} options - The options to be set.
|
|
103
|
+
*/
|
|
104
|
+
static setOptions(options: CssObserverOptions): void;
|
|
105
|
+
/**
|
|
106
|
+
* Debounces a function to limit the number of times it gets called.
|
|
107
|
+
* @param {Function} func - The function to debounce.
|
|
108
|
+
* @param {number} delay - The delay in milliseconds.
|
|
109
|
+
* @returns {Function} A debounced version of the function.
|
|
110
|
+
*/
|
|
111
|
+
private debounce;
|
|
112
|
+
/**
|
|
113
|
+
* Finds the nearest parent element with the tracking attribute.
|
|
114
|
+
* @param {Element} element - The starting element.
|
|
115
|
+
* @returns {Element | null} The nearest parent with the attribute, or null if not found.
|
|
116
|
+
*/
|
|
117
|
+
private findParentWithAttribute;
|
|
118
|
+
/**
|
|
119
|
+
* Adds a tracking attribute to an element.
|
|
120
|
+
* @param {Element} element - The element to tag.
|
|
121
|
+
*/
|
|
122
|
+
private doTag;
|
|
123
|
+
/**
|
|
124
|
+
* Checks if an element has the tracking attribute.
|
|
125
|
+
* @param {Element} element - The element to check.
|
|
126
|
+
* @returns {boolean} True if the element has the tracking attribute, false otherwise.
|
|
127
|
+
*/
|
|
128
|
+
private hasTag;
|
|
129
|
+
/**
|
|
130
|
+
* Tags all elements in the given node and its descendants.
|
|
131
|
+
* @param {Node} element - The root node from which to start tagging.
|
|
132
|
+
*/
|
|
133
|
+
tagAll(element: Node): void;
|
|
134
|
+
/**
|
|
135
|
+
* Adds an event listener for animation start events.
|
|
136
|
+
* @param {Function} eventHandler - The event handler function.
|
|
137
|
+
* @returns {number} The timeout ID.
|
|
138
|
+
*/
|
|
139
|
+
private listenToAnimationEvent;
|
|
140
|
+
/**
|
|
141
|
+
* Removes an event listener for animation start events.
|
|
142
|
+
* @param {Function} eventHandler - The event handler function to remove.
|
|
143
|
+
*/
|
|
144
|
+
private removeEvent;
|
|
145
|
+
/**
|
|
146
|
+
* Creates a style fragment with the specified selector and animation name.
|
|
147
|
+
* @param {string} selector - The CSS selector for the style fragment.
|
|
148
|
+
* @param {string} animationName - The name of the animation.
|
|
149
|
+
* @returns {CSSStyleSheet | HTMLStyleElement} The created style sheet or style element.
|
|
150
|
+
*/
|
|
151
|
+
private createStyleFragment;
|
|
152
|
+
/**
|
|
153
|
+
* Adds a ResizeObserver to track size changes of elements matching the selector.
|
|
154
|
+
* @param {CssObserverCallBack} callback - The callback function to be invoked on resize.
|
|
155
|
+
*/
|
|
156
|
+
private addResizeObserver;
|
|
157
|
+
/**
|
|
158
|
+
* Removes the ResizeObserver if it exists.
|
|
159
|
+
*/
|
|
160
|
+
private removeResizeObserver;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Creates a selector object that allows querying the DOM using CSS selectors.
|
|
164
|
+
* @param {QuerySelector} selector - The CSS selector to query the DOM.
|
|
165
|
+
* @param {Object} [opts] - Optional options for the selector.
|
|
166
|
+
* @param {boolean} [opts.onlyNew] - Whether to observe only new elements.
|
|
167
|
+
* @param {boolean} [opts.trackChildList] - Whether to track child list changes.
|
|
168
|
+
* @param {boolean|string[]} [opts.trackAttributes] - Whether to track attribute changes or an array of specific attributes.
|
|
169
|
+
* @param {boolean} [opts.trackResize] - Whether to track resize events.
|
|
170
|
+
* @returns {Object} An object with methods to track changes.
|
|
171
|
+
*/
|
|
172
|
+
export declare function cssDom(selector: QuerySelector, opts?: {
|
|
173
|
+
onlyNew?: boolean;
|
|
174
|
+
trackChildList?: boolean;
|
|
175
|
+
trackAttributes?: boolean | string[];
|
|
176
|
+
trackResize?: boolean;
|
|
177
|
+
}): {
|
|
178
|
+
each: (callback: CssObserverCallBack) => {
|
|
179
|
+
start: () => void;
|
|
180
|
+
pause: () => void;
|
|
181
|
+
destroy: () => void;
|
|
182
|
+
};
|
|
183
|
+
summary: (callback: CssObserverCallBackSummary) => {
|
|
184
|
+
start: () => void;
|
|
185
|
+
pause: () => void;
|
|
186
|
+
destroy: () => void;
|
|
187
|
+
};
|
|
188
|
+
onReady: (callback: () => void) => void;
|
|
189
|
+
};
|
|
190
|
+
export {};
|