Skip to content

Commit 3ccc52e

Browse files
committed
Fixed once attribute not working with anchor
1 parent 8a79401 commit 3ccc52e

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

dev/jos.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class jos {
2121
scrollProgressDisable = undefined;
2222
disable = false;
2323

24-
static version = "0.9.2 (Development)";
24+
static version = "0.9.3 (Development)";
2525
static author = "Jesvi Jonathan";
2626
static webpage = "https://jos-animation.vercel.app";
2727
static github = "https://github.com/jesvijonathan/JOS-Animation-Library";
@@ -81,14 +81,12 @@ class jos {
8181
if (target.dataset.jos_invoke != undefined) {
8282
window[target.dataset.jos_invoke](target);
8383
}
84-
if (
85-
target.dataset.jos_once != undefined ||
86-
target.dataset.jos_once != "false"
87-
) {
88-
if (target.dataset.jos_once == "true") {
89-
observer.unobserve(target);
90-
} else if (target.dataset.jos_counter >= target.dataset.jos_once) {
91-
observer.unobserve(target);
84+
let parentAnchors = document.querySelectorAll("[data-jos_anchor='#" + parentTarget.id + "']");
85+
if (target.dataset.jos_once && (target.dataset.jos_once == "true" || target.dataset.jos_counter >= target.dataset.jos_once)) {
86+
if (parentAnchors.length < 2) {
87+
observer.unobserve(parentTarget);
88+
} else if (parentAnchors.length > 1) {
89+
target.removeAttribute("data-jos_anchor");
9290
}
9391
}
9492
if (target_jos_animationinverse != undefined) {

0 commit comments

Comments
 (0)