@cocreate/events 1.28.0 → 1.29.0
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.js +48 -48
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.29.0](https://github.com/CoCreate-app/CoCreate-events/compare/v1.28.0...v1.29.0) (2026-01-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* setInterval attribute ([f64f9bc](https://github.com/CoCreate-app/CoCreate-events/commit/f64f9bcc93248c0451b8dcc468d1f0162f3101ea))
|
|
7
|
+
|
|
1
8
|
# [1.28.0](https://github.com/CoCreate-app/CoCreate-events/compare/v1.27.4...v1.28.0) (2026-01-17)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -91,7 +91,7 @@ const CoCreateEvents = {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
let selector = `[${prefix}], [${prefix}-key], [${prefix}-attribute], [${prefix}-value], [${prefix}-action], [${prefix}-query]
|
|
94
|
+
let selector = `[${prefix}], [${prefix}-key], [${prefix}-attribute], [${prefix}-value], [${prefix}-action], [${prefix}-query]`;
|
|
95
95
|
|
|
96
96
|
observer.init({
|
|
97
97
|
name: "CoCreateEventattributes",
|
|
@@ -149,19 +149,6 @@ const CoCreateEvents = {
|
|
|
149
149
|
|
|
150
150
|
if (!events || !isEventable) continue;
|
|
151
151
|
|
|
152
|
-
// let originalSelector = ""; // i think we need to extract the selector and remove the operators
|
|
153
|
-
// if (originalSelector) {
|
|
154
|
-
// observer.init({
|
|
155
|
-
// types: ["addedNodes"],
|
|
156
|
-
// callback: function (mutation) {
|
|
157
|
-
// const els = el.queryElements();
|
|
158
|
-
// if (els && els.includes(mutation.target)) {
|
|
159
|
-
// self.__updateElements();
|
|
160
|
-
// }
|
|
161
|
-
// }
|
|
162
|
-
// });
|
|
163
|
-
// }
|
|
164
|
-
|
|
165
152
|
if (events.includes("onload")) {
|
|
166
153
|
this.__updateElements(el, prefix);
|
|
167
154
|
}
|
|
@@ -255,13 +242,12 @@ const CoCreateEvents = {
|
|
|
255
242
|
entries.forEach((entry) => {
|
|
256
243
|
const isVisible = entry.isIntersecting;
|
|
257
244
|
|
|
258
|
-
// Determine if
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if (isVisible) {
|
|
245
|
+
// Determine if we should trigger based on the "trigger" attribute
|
|
246
|
+
if (
|
|
247
|
+
(trigger === "visible" && isVisible) ||
|
|
248
|
+
(trigger === "not-visible" && !isVisible) ||
|
|
249
|
+
trigger === "both"
|
|
250
|
+
) {
|
|
265
251
|
// Set an attribute to reflect visibility state
|
|
266
252
|
el.setAttribute(
|
|
267
253
|
`${prefix}-is-visible`,
|
|
@@ -272,11 +258,6 @@ const CoCreateEvents = {
|
|
|
272
258
|
self.__updateElements(
|
|
273
259
|
el,
|
|
274
260
|
prefix
|
|
275
|
-
// {
|
|
276
|
-
// isVisible,
|
|
277
|
-
// intersectionRatio:
|
|
278
|
-
// entry.intersectionRatio
|
|
279
|
-
// }
|
|
280
261
|
);
|
|
281
262
|
// Disconnect if once is true
|
|
282
263
|
if (once) {
|
|
@@ -368,23 +349,7 @@ const CoCreateEvents = {
|
|
|
368
349
|
null,
|
|
369
350
|
prefixes[prefix].events
|
|
370
351
|
);
|
|
371
|
-
|
|
372
|
-
// let selector = `[${prefix}], [${prefix}-key], [${prefix}-value], [${prefix}-query]`
|
|
373
|
-
|
|
374
|
-
// let parentElement = target.parentElement;
|
|
375
|
-
// if (parentElement) {
|
|
376
|
-
// do {
|
|
377
|
-
// parentElement = parentElement.closest(selector)
|
|
378
|
-
// if (parentElement) {
|
|
379
|
-
// self.__updateElements(parentElement, prefix, null, prefixes[prefix].events);
|
|
380
|
-
// parentElement = parentElement.parentElement
|
|
381
|
-
// }
|
|
382
|
-
// }
|
|
383
|
-
// while (parentElement)
|
|
384
|
-
|
|
385
|
-
// }
|
|
386
352
|
}
|
|
387
|
-
// }, 500);
|
|
388
353
|
}
|
|
389
354
|
}
|
|
390
355
|
},
|
|
@@ -419,9 +384,48 @@ const CoCreateEvents = {
|
|
|
419
384
|
// });
|
|
420
385
|
// }
|
|
421
386
|
|
|
422
|
-
|
|
423
|
-
|
|
387
|
+
let interval = element.getAttribute(`${prefix}-setInterval`);
|
|
388
|
+
if (interval !== null) {
|
|
389
|
+
let intervalMs = parseInt(interval, 10) || 0;
|
|
390
|
+
if (!element.eventsInterval) {
|
|
391
|
+
element.eventsInterval = {};
|
|
392
|
+
}
|
|
393
|
+
let intervalEntry = element.eventsInterval[prefix];
|
|
394
|
+
if (intervalMs > 0) {
|
|
395
|
+
if (!intervalEntry || intervalEntry.delay !== intervalMs) {
|
|
396
|
+
if (intervalEntry) {
|
|
397
|
+
clearInterval(intervalEntry.id);
|
|
398
|
+
}
|
|
399
|
+
element.eventsInterval[prefix] = {
|
|
400
|
+
delay: intervalMs,
|
|
401
|
+
id: setInterval(() => {
|
|
402
|
+
if (!element.isConnected) {
|
|
403
|
+
const entry =
|
|
404
|
+
element.eventsInterval &&
|
|
405
|
+
element.eventsInterval[prefix];
|
|
406
|
+
if (entry) {
|
|
407
|
+
clearInterval(entry.id);
|
|
408
|
+
delete element.eventsInterval[prefix];
|
|
409
|
+
}
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
self.__updateElements(
|
|
413
|
+
element,
|
|
414
|
+
prefix,
|
|
415
|
+
target,
|
|
416
|
+
events,
|
|
417
|
+
params
|
|
418
|
+
);
|
|
419
|
+
}, intervalMs)
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
} else if (intervalEntry) {
|
|
423
|
+
clearInterval(intervalEntry.id);
|
|
424
|
+
delete element.eventsInterval[prefix];
|
|
425
|
+
}
|
|
426
|
+
}
|
|
424
427
|
|
|
428
|
+
let delay = element.getAttribute(`${prefix}-setTimeout`);
|
|
425
429
|
if (delay) {
|
|
426
430
|
delay = parseInt(delay, 10) || 0;
|
|
427
431
|
if (delay > 0) {
|
|
@@ -447,9 +451,6 @@ const CoCreateEvents = {
|
|
|
447
451
|
let targetPosition = element.getAttribute(
|
|
448
452
|
`${prefix}-insert-adjacent`
|
|
449
453
|
);
|
|
450
|
-
// targetAttribute = checkMediaQueries(targetAttribute)
|
|
451
|
-
// if (targetAttribute === false)
|
|
452
|
-
// return
|
|
453
454
|
|
|
454
455
|
let onEvent = element.getAttribute(`${prefix}-on`);
|
|
455
456
|
if (onEvent) {
|
|
@@ -474,7 +475,6 @@ const CoCreateEvents = {
|
|
|
474
475
|
}
|
|
475
476
|
}
|
|
476
477
|
|
|
477
|
-
// if (!key || !values)
|
|
478
478
|
if (!key) return;
|
|
479
479
|
} else {
|
|
480
480
|
values = element.getAttribute(`${prefix}-value`);
|