We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e8f4c2d commit e58bfeeCopy full SHA for e58bfee
1 file changed
src/index.js
@@ -245,6 +245,10 @@ const CoCreateEvents = {
245
? threshold.filter((value) => value >= 0 && value <= 1)
246
: [0];
247
248
+ // Returns true if attribute is present AND does not equal "false"
249
+ const onceAttr = el.getAttribute(`${prefix}-once`);
250
+ const once = onceAttr !== null && onceAttr !== "false";
251
+
252
// Create IntersectionObserver
253
const intersectionObserver = new IntersectionObserver(
254
(entries) => {
@@ -274,6 +278,10 @@ const CoCreateEvents = {
274
278
// entry.intersectionRatio
275
279
// }
276
280
);
281
+ // Disconnect if once is true
282
+ if (once) {
283
+ intersectionObserver.unobserve(entry.target);
284
+ }
277
285
}
286
});
287
},
0 commit comments