jos-animation 0.8.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/.github/FUNDING.yml +13 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.prettierignore +8 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +18 -0
- package/LEARN.md +3 -0
- package/LICENSE.md +21 -0
- package/README.md +453 -0
- package/SECURITY.md +19 -0
- package/dev/index.html +422 -0
- package/dev/jos.css +647 -0
- package/dev/jos.js +413 -0
- package/dev/scroll.js +18 -0
- package/dist/.htaccess +0 -0
- package/dist/jos.css +1 -0
- package/dist/jos.debug.js +414 -0
- package/dist/jos.js +309 -0
- package/dist/jos.min.js +1 -0
- package/dist/v0.3/jos.css +225 -0
- package/dist/v0.3/jos.js +161 -0
- package/dist/v0.5/jos.css +250 -0
- package/dist/v0.5/jos.js +473 -0
- package/dist/v0.6/jos.css +250 -0
- package/dist/v0.6/jos.debug.js +2 -0
- package/dist/v0.6/jos.debug.min.js +2 -0
- package/dist/v0.6/jos.js +212 -0
- package/dist/v0.6/jos.min.js +2 -0
- package/dist/v0.7/.htaccess +0 -0
- package/dist/v0.7/jos.css +2 -0
- package/dist/v0.7/jos.debug.js +459 -0
- package/dist/v0.7/jos.dev.js +623 -0
- package/dist/v0.7/jos.js +264 -0
- package/dist/v0.7/jos.min.js +2 -0
- package/dist/v0.8/jos.css +1 -0
- package/dist/v0.8/jos.debug.js +414 -0
- package/dist/v0.8/jos.js +309 -0
- package/dist/v0.8/jos.min.js +1 -0
- package/docs/index.html +419 -0
- package/docs/index2.html +678 -0
- package/docs/indexOld.html +291 -0
- package/docs/style.css +216 -0
- package/package.json +31 -0
- package/res/7ygwKRQc_2x.jpg +0 -0
- package/res/NewvWJ8Z_2x.jpg +0 -0
- package/res/asdsad.jpg +0 -0
- package/res/cPowTYfI_2x.jpg +0 -0
- package/res/favicon.ico +0 -0
- package/res/logo.jpg +0 -0
- package/res/logo_1_sq.png +0 -0
- package/res/logo_1png-removebg-preview.png +0 -0
- package/res/logo_1png.png +0 -0
- package/res/logo_2-removebg-preview.png +0 -0
- package/res/logo_2.png +0 -0
- package/res/logo_2_sq.png +0 -0
package/dist/v0.8/jos.js
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
class jos {
|
|
2
|
+
default_once = !1;
|
|
3
|
+
default_animation = "fade";
|
|
4
|
+
default_animationinverse = void 0;
|
|
5
|
+
default_timingFunction = "ease-in-out";
|
|
6
|
+
default_threshold = 0;
|
|
7
|
+
default_duration = 0.4;
|
|
8
|
+
default_delay = 0;
|
|
9
|
+
default_intersectionRatio = 0;
|
|
10
|
+
default_rootMargin = "-10% 0% -40% 0%";
|
|
11
|
+
default_startVisible = void 0;
|
|
12
|
+
default_scrolldirection = void 0;
|
|
13
|
+
default_passive = !0;
|
|
14
|
+
debug = !1;
|
|
15
|
+
disable = !1;
|
|
16
|
+
static version = "0.8.1";
|
|
17
|
+
static author = "Jesvi Jonathan";
|
|
18
|
+
static github = "https://github.com/jesvijonathan/JOS-Animation-Library";
|
|
19
|
+
options = {};
|
|
20
|
+
jos_stylesheet = void 0;
|
|
21
|
+
boxes = void 0;
|
|
22
|
+
observers = [];
|
|
23
|
+
constructor() {}
|
|
24
|
+
version() {
|
|
25
|
+
console.log(
|
|
26
|
+
`JOS: Javascript On Scroll Animation Library\n - Version: ${jos.version}\n - Author: ${jos.author}\n - Github: ${jos.github}\n`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
debugger(type = 0) {
|
|
30
|
+
0 == type && this.debugMode && this.version(),
|
|
31
|
+
console.log("JOS Initialized:\n\n");
|
|
32
|
+
}
|
|
33
|
+
callbackRouter_anchor = (entries, observer) => {
|
|
34
|
+
let entry = entries[0],
|
|
35
|
+
parentTarget = entry.target;
|
|
36
|
+
document
|
|
37
|
+
.querySelectorAll("[data-jos_anchor='#" + parentTarget.id + "']")
|
|
38
|
+
.forEach((target) => {
|
|
39
|
+
let target_jos_animation = target.dataset.jos_animation,
|
|
40
|
+
target_jos_animationinverse = target.dataset.jos_animationinverse;
|
|
41
|
+
if (entry.isIntersecting) {
|
|
42
|
+
if (null != target.dataset.jos_counter) {
|
|
43
|
+
let counter_value = parseInt(target.dataset.jos_counter);
|
|
44
|
+
counter_value++, (target.dataset.jos_counter = counter_value);
|
|
45
|
+
}
|
|
46
|
+
target_jos_animation &&
|
|
47
|
+
(target.classList.remove("jos-" + target_jos_animation),
|
|
48
|
+
null != target.dataset.jos_invoke &&
|
|
49
|
+
window[target.dataset.jos_invoke](target),
|
|
50
|
+
(null == target.dataset.jos_once &&
|
|
51
|
+
"false" == target.dataset.jos_once) ||
|
|
52
|
+
(("true" == target.dataset.jos_once ||
|
|
53
|
+
target.dataset.jos_counter >= target.dataset.jos_once) &&
|
|
54
|
+
observer.unobserve(target)),
|
|
55
|
+
null != target_jos_animationinverse &&
|
|
56
|
+
target.classList.add("jos-" + target_jos_animationinverse));
|
|
57
|
+
} else
|
|
58
|
+
(void 0 !== target.dataset.jos_scrolldirection &&
|
|
59
|
+
"down" !== target.dataset.jos_scrolldirection &&
|
|
60
|
+
"none" !== target.dataset.jos_scrolldirection) ||
|
|
61
|
+
(target.classList.add("jos-" + target_jos_animation),
|
|
62
|
+
void 0 !== target.dataset.jos_invoke_out &&
|
|
63
|
+
window[target.dataset.jos_invoke_out](target));
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
callbackRouter = (entries, observer, type = 1) => {
|
|
67
|
+
if (1 == this.disable) return;
|
|
68
|
+
let entry = entries[0],
|
|
69
|
+
target = entry.target,
|
|
70
|
+
target_jos_animation = target.dataset.jos_animation,
|
|
71
|
+
target_jos_animationinverse = target.dataset.jos_animationinverse,
|
|
72
|
+
scroll_dir = 1;
|
|
73
|
+
if (
|
|
74
|
+
((scroll_dir = entry.boundingClientRect.top < 0 ? 0 : 1),
|
|
75
|
+
entry.isIntersecting)
|
|
76
|
+
) {
|
|
77
|
+
if (null != target.dataset.jos_counter) {
|
|
78
|
+
let counter_value = parseInt(target.dataset.jos_counter);
|
|
79
|
+
counter_value++, (target.dataset.jos_counter = counter_value);
|
|
80
|
+
}
|
|
81
|
+
target_jos_animation &&
|
|
82
|
+
(target.classList.remove("jos-" + target_jos_animation),
|
|
83
|
+
null != target.dataset.jos_invoke &&
|
|
84
|
+
window[target.dataset.jos_invoke](target),
|
|
85
|
+
(null == target.dataset.jos_once &&
|
|
86
|
+
"false" == target.dataset.jos_once) ||
|
|
87
|
+
(("true" == target.dataset.jos_once ||
|
|
88
|
+
target.dataset.jos_counter >= target.dataset.jos_once) &&
|
|
89
|
+
observer.unobserve(target))),
|
|
90
|
+
null != target_jos_animationinverse &&
|
|
91
|
+
target.classList.add("jos-" + target_jos_animationinverse);
|
|
92
|
+
} else
|
|
93
|
+
(void 0 === target.dataset.jos_scrolldirection ||
|
|
94
|
+
(1 === scroll_dir && "down" === target.dataset.jos_scrolldirection) ||
|
|
95
|
+
(0 === scroll_dir && "up" === target.dataset.jos_scrolldirection) ||
|
|
96
|
+
"none" === target.dataset.jos_scrolldirection) &&
|
|
97
|
+
(target.classList.add("jos-" + target_jos_animation),
|
|
98
|
+
null != target_jos_animationinverse &&
|
|
99
|
+
target.classList.remove("jos-" + target_jos_animationinverse),
|
|
100
|
+
void 0 !== target.dataset.jos_invoke_out &&
|
|
101
|
+
window[target.dataset.jos_invoke_out](target));
|
|
102
|
+
};
|
|
103
|
+
animationInit() {
|
|
104
|
+
let doit = [];
|
|
105
|
+
this.boxes.forEach((box) => {
|
|
106
|
+
let object_default_once = box.dataset.jos_once,
|
|
107
|
+
object_default_animation =
|
|
108
|
+
box.dataset.jos_animation || this.default_animation,
|
|
109
|
+
object_default_animationinverse = box.dataset.jos_animationinverse,
|
|
110
|
+
object_default_timingFunction = box.dataset.jos_timingFunction,
|
|
111
|
+
object_default_duration = box.dataset.jos_duration,
|
|
112
|
+
object_default_delay = box.dataset.jos_delay;
|
|
113
|
+
box.classList.contains("jos_disabled") &&
|
|
114
|
+
(box.classList.remove("jos_disabled"), box.classList.add("jos")),
|
|
115
|
+
object_default_once &&
|
|
116
|
+
("true" == object_default_once || /^\d+$/.test(object_default_once))
|
|
117
|
+
? box.setAttribute("data-jos_once", object_default_once)
|
|
118
|
+
: box.setAttribute(
|
|
119
|
+
"data-jos_once",
|
|
120
|
+
this.default_once ? "1" : "false"
|
|
121
|
+
),
|
|
122
|
+
box.setAttribute("data-jos_animation", object_default_animation),
|
|
123
|
+
object_default_animationinverse &&
|
|
124
|
+
box.setAttribute(
|
|
125
|
+
"data-jos_animationinverse",
|
|
126
|
+
object_default_animationinverse
|
|
127
|
+
),
|
|
128
|
+
object_default_timingFunction &&
|
|
129
|
+
box.setAttribute(
|
|
130
|
+
"data-jos_timingFunction",
|
|
131
|
+
object_default_timingFunction
|
|
132
|
+
),
|
|
133
|
+
object_default_duration &&
|
|
134
|
+
box.setAttribute("data-jos_duration", object_default_duration),
|
|
135
|
+
object_default_delay &&
|
|
136
|
+
box.setAttribute("data-jos_delay", object_default_delay),
|
|
137
|
+
box.setAttribute("data-jos_counter", "0"),
|
|
138
|
+
box.classList.add("jos-" + object_default_animation),
|
|
139
|
+
(box.dataset.jos_startvisible || this.default_startVisible) &&
|
|
140
|
+
doit.push(box),
|
|
141
|
+
this.default_scrolldirection &&
|
|
142
|
+
box.setAttribute(
|
|
143
|
+
"data-jos_scrolldirection",
|
|
144
|
+
this.default_scrolldirection
|
|
145
|
+
);
|
|
146
|
+
let box_observer = {
|
|
147
|
+
rootMargin: [
|
|
148
|
+
box.dataset.jos_rootmargin_top ||
|
|
149
|
+
this.default_rootMargin.split(" ")[0],
|
|
150
|
+
box.dataset.jos_rootmargin_left ||
|
|
151
|
+
this.default_rootMargin.split(" ")[3],
|
|
152
|
+
box.dataset.jos_rootmargin_bottom ||
|
|
153
|
+
this.default_rootMargin.split(" ")[2],
|
|
154
|
+
box.dataset.jos_rootmargin_left ||
|
|
155
|
+
this.default_rootMargin.split(" ")[1],
|
|
156
|
+
].join(" "),
|
|
157
|
+
threshold: this.default_threshold,
|
|
158
|
+
passive: this.default_passive,
|
|
159
|
+
};
|
|
160
|
+
if (box.dataset.jos_anchor) {
|
|
161
|
+
const observer = new IntersectionObserver(
|
|
162
|
+
this.callbackRouter_anchor,
|
|
163
|
+
box_observer
|
|
164
|
+
);
|
|
165
|
+
this.observers.push(observer),
|
|
166
|
+
observer.observe(
|
|
167
|
+
document.getElementById(box.dataset.jos_anchor.substring(1))
|
|
168
|
+
);
|
|
169
|
+
} else {
|
|
170
|
+
const observer = new IntersectionObserver(
|
|
171
|
+
this.callbackRouter,
|
|
172
|
+
box_observer
|
|
173
|
+
);
|
|
174
|
+
this.observers.push(observer), observer.observe(box);
|
|
175
|
+
}
|
|
176
|
+
}),
|
|
177
|
+
setTimeout(() => {
|
|
178
|
+
doit.forEach((box) => {
|
|
179
|
+
let box_time = box.dataset.jos_startvisible;
|
|
180
|
+
setTimeout(() => {
|
|
181
|
+
"true" == box_time && (box_time = 0),
|
|
182
|
+
box.classList.remove("jos-" + box.dataset.jos_animation);
|
|
183
|
+
}, box_time || this.default_startVisible);
|
|
184
|
+
});
|
|
185
|
+
}, 100);
|
|
186
|
+
}
|
|
187
|
+
animationUnset(state = 0) {
|
|
188
|
+
-1 != state &&
|
|
189
|
+
this.boxes?.forEach((box) => {
|
|
190
|
+
box.classList.remove("jos"),
|
|
191
|
+
box.classList.add("jos_disabled"),
|
|
192
|
+
0 == state
|
|
193
|
+
? box.classList.add("jos-" + box.dataset.jos_animation)
|
|
194
|
+
: box.classList.remove("jos-" + box.dataset.jos_animation);
|
|
195
|
+
}),
|
|
196
|
+
this.observers?.forEach((observer) => observer.disconnect());
|
|
197
|
+
}
|
|
198
|
+
getstylesheet() {
|
|
199
|
+
return (
|
|
200
|
+
this.jos_stylesheet ||
|
|
201
|
+
(this.jos_stylesheet = document.getElementById("jos-stylesheet").sheet),
|
|
202
|
+
this.jos_stylesheet.insertRule(
|
|
203
|
+
".jos {transition: " +
|
|
204
|
+
this.default_duration +
|
|
205
|
+
"s " +
|
|
206
|
+
this.default_timingFunction +
|
|
207
|
+
" " +
|
|
208
|
+
this.default_delay +
|
|
209
|
+
"s !important;}"
|
|
210
|
+
),
|
|
211
|
+
this.jos_stylesheet
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
getBoxes() {
|
|
215
|
+
return (
|
|
216
|
+
(this.boxes = void 0),
|
|
217
|
+
this.boxes || (this.boxes = document.querySelectorAll(".jos")),
|
|
218
|
+
this.boxes
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
getdefault(options = {}) {
|
|
222
|
+
let {
|
|
223
|
+
once: once,
|
|
224
|
+
animation: animation,
|
|
225
|
+
animationinverse: animationinverse,
|
|
226
|
+
timingFunction: timingFunction,
|
|
227
|
+
threshold: threshold,
|
|
228
|
+
startVisible: startVisible,
|
|
229
|
+
scrollDirection: scrollDirection,
|
|
230
|
+
intersectionRatio: intersectionRatio,
|
|
231
|
+
duration: duration,
|
|
232
|
+
delay: delay,
|
|
233
|
+
debugMode: debugMode,
|
|
234
|
+
disable: disable,
|
|
235
|
+
rootMargin: rootMargin,
|
|
236
|
+
rootMarginTop: rootMarginTop,
|
|
237
|
+
rootMarginBottom: rootMarginBottom,
|
|
238
|
+
} = options;
|
|
239
|
+
(this.default_once = once || this.default_once),
|
|
240
|
+
(this.default_animation = animation || this.default_animation),
|
|
241
|
+
(this.default_animationinverse =
|
|
242
|
+
animationinverse || this.default_animation),
|
|
243
|
+
(this.default_timingFunction =
|
|
244
|
+
timingFunction || this.default_timingFunction),
|
|
245
|
+
(this.default_threshold = threshold || this.default_threshold),
|
|
246
|
+
(this.default_startVisible = startVisible || this.default_startVisible),
|
|
247
|
+
(this.default_scrolldirection =
|
|
248
|
+
scrollDirection || this.default_scrolldirection),
|
|
249
|
+
(this.default_intersectionRatio =
|
|
250
|
+
intersectionRatio || this.default_threshold),
|
|
251
|
+
(this.default_duration = duration || this.default_duration),
|
|
252
|
+
(this.default_delay = delay || this.default_delay),
|
|
253
|
+
(this.debugMode = debugMode || this.debugMode),
|
|
254
|
+
(this.disable = disable || this.disable),
|
|
255
|
+
(this.default_rootMargin =
|
|
256
|
+
rootMargin ||
|
|
257
|
+
`${rootMarginTop || "-10%"} 0% ${rootMarginBottom || "-40%"} 0%`);
|
|
258
|
+
}
|
|
259
|
+
init(options = this.options) {
|
|
260
|
+
(this.options = options),
|
|
261
|
+
this.getdefault(options),
|
|
262
|
+
this.getstylesheet(),
|
|
263
|
+
this.getBoxes(),
|
|
264
|
+
this.debugMode &&
|
|
265
|
+
console.warn(
|
|
266
|
+
"JOS | This version of JOS package does not support debug mode, Please use jos.debug.js for debugging."
|
|
267
|
+
),
|
|
268
|
+
this.disable ? this.stop() : this.start();
|
|
269
|
+
}
|
|
270
|
+
start(state = 0) {
|
|
271
|
+
return (
|
|
272
|
+
-1 != state && (this.stop(), this.animationInit()),
|
|
273
|
+
(this.disable = !1),
|
|
274
|
+
"Started"
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
stop(state = 0) {
|
|
278
|
+
return (
|
|
279
|
+
1 == state ? (state = 0) : 0 == state && (state = 1),
|
|
280
|
+
(this.disable = !0),
|
|
281
|
+
-1 != state && this.animationUnset(state),
|
|
282
|
+
"Stopped"
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
refresh() {
|
|
286
|
+
return (
|
|
287
|
+
this.animationUnset(-1),
|
|
288
|
+
(this.boxes = void 0),
|
|
289
|
+
this.getBoxes(),
|
|
290
|
+
this.animationInit(),
|
|
291
|
+
this.debugger(1),
|
|
292
|
+
"Refreshed"
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
destroy(state = 0) {
|
|
296
|
+
this.animationUnset(-1),
|
|
297
|
+
(this.boxes = void 0),
|
|
298
|
+
(this.observers = []),
|
|
299
|
+
1 == state && (this.jos_stylesheet.disabled = !0),
|
|
300
|
+
(this.jos_stylesheet = void 0);
|
|
301
|
+
for (let prop in this)
|
|
302
|
+
this.hasOwnProperty(prop) &&
|
|
303
|
+
"function" != typeof this[prop] &&
|
|
304
|
+
(this[prop] = void 0);
|
|
305
|
+
return Object.setPrototypeOf(this, null), "JOS Instance Nuked";
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
const JOS = new jos();
|
|
309
|
+
// By Jesvi Jonathan
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class jos{default_once=!1;default_animation="fade";default_animationinverse=void 0;default_timingFunction="ease-in-out";default_threshold=0;default_duration=.4;default_delay=0;default_intersectionRatio=0;default_rootMargin="-10% 0% -40% 0%";default_startVisible=void 0;default_scrolldirection=void 0;default_passive=!0;debug=!1;disable=!1;static version="0.8.1 (Minified)";static author="Jesvi Jonathan";static github="https://github.com/jesvijonathan/JOS-Animation-Library";options={};jos_stylesheet=void 0;boxes=void 0;observers=[];constructor(){}version(){console.log(`JOS: Javascript On Scroll Animation Library\n - Version: ${jos.version}\n - Author: ${jos.author}\n - Github: ${jos.github}\n`)}debugger=()=>this.version();callbackRouter_anchor=(t,s)=>{let e=t[0],o=e.target;document.querySelectorAll("[data-jos_anchor='#"+o.id+"']").forEach((t=>{let o=t.dataset.jos_animation,i=t.dataset.jos_animationinverse;if(e.isIntersecting){if(null!=t.dataset.jos_counter){let s=parseInt(t.dataset.jos_counter);s++,t.dataset.jos_counter=s}o&&(t.classList.remove("jos-"+o),null!=t.dataset.jos_invoke&&window[t.dataset.jos_invoke](t),null==t.dataset.jos_once&&"false"==t.dataset.jos_once||("true"==t.dataset.jos_once||t.dataset.jos_counter>=t.dataset.jos_once)&&s.unobserve(t),null!=i&&t.classList.add("jos-"+i))}else void 0!==t.dataset.jos_scrolldirection&&"down"!==t.dataset.jos_scrolldirection&&"none"!==t.dataset.jos_scrolldirection||(t.classList.add("jos-"+o),void 0!==t.dataset.jos_invoke_out&&window[t.dataset.jos_invoke_out](t))}))};callbackRouter=(t,s,e=1)=>{if(1==this.disable)return;let o=t[0],i=o.target,a=i.dataset.jos_animation,n=i.dataset.jos_animationinverse,d=1;if(d=o.boundingClientRect.top<0?0:1,o.isIntersecting){if(null!=i.dataset.jos_counter){let t=parseInt(i.dataset.jos_counter);t++,i.dataset.jos_counter=t}a&&(i.classList.remove("jos-"+a),null!=i.dataset.jos_invoke&&window[i.dataset.jos_invoke](i),null==i.dataset.jos_once&&"false"==i.dataset.jos_once||("true"==i.dataset.jos_once||i.dataset.jos_counter>=i.dataset.jos_once)&&s.unobserve(i)),null!=n&&i.classList.add("jos-"+n)}else(void 0===i.dataset.jos_scrolldirection||1===d&&"down"===i.dataset.jos_scrolldirection||0===d&&"up"===i.dataset.jos_scrolldirection||"none"===i.dataset.jos_scrolldirection)&&(i.classList.add("jos-"+a),null!=n&&i.classList.remove("jos-"+n),void 0!==i.dataset.jos_invoke_out&&window[i.dataset.jos_invoke_out](i))};animationInit(){let t=[];this.boxes.forEach((s=>{let e=s.dataset.jos_once,o=s.dataset.jos_animation||this.default_animation,i=s.dataset.jos_animationinverse,a=s.dataset.jos_timingFunction,n=s.dataset.jos_duration,d=s.dataset.jos_delay;s.classList.contains("jos_disabled")&&(s.classList.remove("jos_disabled"),s.classList.add("jos")),e&&("true"==e||/^\d+$/.test(e))?s.setAttribute("data-jos_once",e):s.setAttribute("data-jos_once",this.default_once?"1":"false"),s.setAttribute("data-jos_animation",o),i&&s.setAttribute("data-jos_animationinverse",i),a&&s.setAttribute("data-jos_timingFunction",a),n&&s.setAttribute("data-jos_duration",n),d&&s.setAttribute("data-jos_delay",d),s.setAttribute("data-jos_counter","0"),s.classList.add("jos-"+o),(s.dataset.jos_startvisible||this.default_startVisible)&&t.push(s),this.default_scrolldirection&&s.setAttribute("data-jos_scrolldirection",this.default_scrolldirection);let r={rootMargin:[s.dataset.jos_rootmargin_top||this.default_rootMargin.split(" ")[0],s.dataset.jos_rootmargin_left||this.default_rootMargin.split(" ")[3],s.dataset.jos_rootmargin_bottom||this.default_rootMargin.split(" ")[2],s.dataset.jos_rootmargin_left||this.default_rootMargin.split(" ")[1]].join(" "),threshold:this.default_threshold,passive:this.default_passive};if(s.dataset.jos_anchor){const t=new IntersectionObserver(this.callbackRouter_anchor,r);this.observers.push(t),t.observe(document.getElementById(s.dataset.jos_anchor.substring(1)))}else{const t=new IntersectionObserver(this.callbackRouter,r);this.observers.push(t),t.observe(s)}})),setTimeout((()=>{t.forEach((t=>{let s=t.dataset.jos_startvisible;setTimeout((()=>{"true"==s&&(s=0),t.classList.remove("jos-"+t.dataset.jos_animation)}),s||this.default_startVisible)}))}),100)}animationUnset(t=0){-1!=t&&this.boxes?.forEach((s=>{s.classList.remove("jos"),s.classList.add("jos_disabled"),0==t?s.classList.add("jos-"+s.dataset.jos_animation):s.classList.remove("jos-"+s.dataset.jos_animation)})),this.observers?.forEach((t=>t.disconnect()))}getstylesheet(){return this.jos_stylesheet||(this.jos_stylesheet=document.getElementById("jos-stylesheet").sheet),this.jos_stylesheet.insertRule(".jos {transition: "+this.default_duration+"s "+this.default_timingFunction+" "+this.default_delay+"s !important;}"),this.jos_stylesheet}getBoxes(){return this.boxes=void 0,this.boxes||(this.boxes=document.querySelectorAll(".jos")),this.boxes}getdefault(t={}){let{once:s,animation:e,animationinverse:o,timingFunction:i,threshold:a,startVisible:n,scrollDirection:d,intersectionRatio:r,duration:l,delay:u,debugMode:h,disable:_,rootMargin:c,rootMarginTop:j,rootMarginBottom:f}=t;this.default_once=s||this.default_once,this.default_animation=e||this.default_animation,this.default_animationinverse=o||this.default_animation,this.default_timingFunction=i||this.default_timingFunction,this.default_threshold=a||this.default_threshold,this.default_startVisible=n||this.default_startVisible,this.default_scrolldirection=d||this.default_scrolldirection,this.default_intersectionRatio=r||this.default_threshold,this.default_duration=l||this.default_duration,this.default_delay=u||this.default_delay,this.debugMode=h||this.debugMode,this.disable=_||this.disable,this.default_rootMargin=c||`${j||"-10%"} 0% ${f||"-40%"} 0%`}init(t=this.options){this.options=t,this.getdefault(t),this.getstylesheet(),this.getBoxes(),this.debugMode&&console.warn("JOS | This version of JOS package does not support debug mode, Please use jos.debug.js for debugging."),this.disable?this.stop():this.start()}start(t=0){return-1!=t&&(this.stop(),this.animationInit()),this.disable=!1,"Started"}stop(t=0){return 1==t?t=0:0==t&&(t=1),this.disable=!0,-1!=t&&this.animationUnset(t),"Stopped"}refresh(){return this.animationUnset(-1),this.boxes=void 0,this.getBoxes(),this.animationInit(),this.debugger(1),"Refreshed"}destroy(t=0){this.animationUnset(-1),this.boxes=void 0,this.observers=[],1==t&&(this.jos_stylesheet.disabled=!0),this.jos_stylesheet=void 0;for(let t in this)this.hasOwnProperty(t)&&"function"!=typeof this[t]&&(this[t]=void 0);return Object.setPrototypeOf(this,null),"JOS Instance Nuked"}}const JOS=new jos;// By Jesvi Jonathan
|