jos-animation 0.8.1 → 0.8.7-beta.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 +30 -3
- package/dev/jos.css +635 -0
- package/dev/jos.js +526 -0
- package/dev/scroll.js +18 -0
- package/dist/jos.js +2 -0
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -73,23 +73,30 @@ Feel free to report an issue or request a feature in this repository :)
|
|
|
73
73
|
- [JavaScript](https://www.w3schools.com/js/)
|
|
74
74
|
- [CSS](https://www.w3schools.com/css/)
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
### Installation
|
|
77
77
|
|
|
78
78
|
1. Add the <code>[\<link>](https://github.com/jesvijonathan/Jesvi-Bot/releases)</code> inside the <code>\<head></code> tag :
|
|
79
79
|
|
|
80
|
+
<!-- https://unpkg.com/jos-animation@latest/dist/jos.js -->
|
|
81
|
+
<!-- "https://cdn.jsdelivr.net/gh/jesvijonathan/JOS-Animation-Library/dist/v0.8/jos.css" -->
|
|
82
|
+
|
|
80
83
|
```html
|
|
81
84
|
<link
|
|
82
85
|
id="jos-stylesheet"
|
|
83
86
|
rel="stylesheet"
|
|
84
|
-
href="https://
|
|
87
|
+
href="https://unpkg.com/jos-animation/dist/jos.css"
|
|
85
88
|
crossorigin="anonymous"
|
|
86
89
|
/>
|
|
87
90
|
```
|
|
88
91
|
|
|
89
92
|
2. Add the <code>[\<script>](https://github.com/jesvijonathan/Jesvi-Bot/releases)</code> right after the <code>\<body></code> tag :
|
|
93
|
+
<!-- For easier navigation use jsdelivr -->
|
|
94
|
+
<!-- https://cdn.jsdelivr.net/gh/jesvijonathan/JOS-Animation-Library/dist/v0.8/jos.min.js -->
|
|
95
|
+
<!-- For Stablility use unpkg -->
|
|
96
|
+
<!-- https://unpkg.com/jos-animation@latest/dist/jos.js -->
|
|
90
97
|
|
|
91
98
|
```html
|
|
92
|
-
<script src="https://
|
|
99
|
+
<script src="https://unpkg.com/jos-animation/dist/jos.min.js"></script>
|
|
93
100
|
```
|
|
94
101
|
|
|
95
102
|
You can add minified version of the script by replacing <code>jos.js</code> with <code>jos.min.js</code> in the above script tag.
|
|
@@ -131,6 +138,25 @@ By the end of this step, you should have something like this :
|
|
|
131
138
|
</html>
|
|
132
139
|
``` -->
|
|
133
140
|
|
|
141
|
+
<!-- using npm -->
|
|
142
|
+
|
|
143
|
+
<!-- ### Installation using npm
|
|
144
|
+
|
|
145
|
+
1. You can also Install JOS using npm :
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
npm install jos-animation
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
2. Import JOS in your project :
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
import "jos-animation/dist/jos.css";
|
|
155
|
+
import JOS from "jos-animation";
|
|
156
|
+
|
|
157
|
+
JOS.init();
|
|
158
|
+
``` -->
|
|
159
|
+
|
|
134
160
|
## Setup :
|
|
135
161
|
|
|
136
162
|
1. Use <code>JOS.init();</code> to initialize the library with default settings.
|
|
@@ -156,6 +182,7 @@ By the end of this step, you should have something like this :
|
|
|
156
182
|
animation: "fade", // JOS global animation type | Values : 'fade', 'slide', 'zoom', 'flip', 'fade-right', 'fade-left', 'fade-up', 'fade-down', 'zoom-in-right', 'zoom-in-left', 'zoom-in-up', 'zoom-in-down', 'zoom-out-right', 'zoom-out-left', 'zoom-out-up', 'zoom-out-down', 'flip-right', 'flip-left', 'flip-up', 'flip-down, spin, revolve, stretch, "my-custom-animation"
|
|
157
183
|
// animationInverse: "static", // Set the animation type for the element when it is scrolled out of view | Values : 'fade', 'slide', 'zoom', 'flip', 'fade-right', 'fade-left', 'fade-up', 'fade-down', 'zoom-in-right', 'zoom-in-left', 'zoom-in-up', 'zoom-in-down', 'zoom-out-right', 'zoom-out-left', 'zoom-out-up', 'zoom-out-down', 'flip-right', 'flip-left', 'flip-up', 'flip-down, spin, revolve, stretch, "my-custom-animation"
|
|
158
184
|
timingFunction: "ease-in-out", // JOS global timing function | Values : 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear', 'step-start', 'step-end', 'steps()', 'cubic-bezier()', 'my-custom-timing-function'
|
|
185
|
+
//mirror : false, // Set whether the element should animate back when scrolled out of view | Values : 'true', 'false'
|
|
159
186
|
threshold: 0, // Set gloabal the threshold for the element to be visible | Values : 0-1
|
|
160
187
|
delay: 0, // Set global the delay for the animation to start | Values : 0,1,2,3,4,5
|
|
161
188
|
duration: 0.7, // Set global the duration for the animation playback | Values : flota : 0-1 & int : 0,1,2,3,4,5
|
package/dev/jos.css
ADDED
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
/*
|
|
2
|
+
JOS v0.8.4 By Jesvi Jonathan
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/* jos default */
|
|
6
|
+
.jos {
|
|
7
|
+
/* opacity: 1;
|
|
8
|
+
display: block; */
|
|
9
|
+
|
|
10
|
+
transition: opacity 0.4s, transform 0.4s;
|
|
11
|
+
/* transition: 0.4s; */
|
|
12
|
+
transition-timing-function: ease-in-out;
|
|
13
|
+
}
|
|
14
|
+
/* .jos:not([class]):not([class*="display"]):not(:has([class*="display"])) {
|
|
15
|
+
display: block;
|
|
16
|
+
} */
|
|
17
|
+
|
|
18
|
+
.jos-anchor {
|
|
19
|
+
opacity: 0;
|
|
20
|
+
transition: opacity 0.4s, transform 0.4s;
|
|
21
|
+
transition-timing-function: ease-in-out;
|
|
22
|
+
}
|
|
23
|
+
.jos-static {
|
|
24
|
+
transform: translate(0, 0);
|
|
25
|
+
opacity: 1;
|
|
26
|
+
}
|
|
27
|
+
.jos-no-transition {
|
|
28
|
+
transition-timing-function: linear;
|
|
29
|
+
transition-duration: 0s;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* .jos-no-mirror {
|
|
33
|
+
transition: 0s forwards !important;
|
|
34
|
+
} */
|
|
35
|
+
|
|
36
|
+
/* fade */
|
|
37
|
+
.jos-fade {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
}
|
|
40
|
+
.jos-fade-right {
|
|
41
|
+
opacity: 0;
|
|
42
|
+
transform: translateX(-100px);
|
|
43
|
+
}
|
|
44
|
+
.jos-fade-left {
|
|
45
|
+
opacity: 0;
|
|
46
|
+
transform: translateX(100px);
|
|
47
|
+
}
|
|
48
|
+
.jos-fade-up {
|
|
49
|
+
opacity: 0;
|
|
50
|
+
transform: translateY(50px);
|
|
51
|
+
}
|
|
52
|
+
.jos-fade-down {
|
|
53
|
+
opacity: 0;
|
|
54
|
+
transform: translateY(-50px);
|
|
55
|
+
}
|
|
56
|
+
.jos-fade-right-up {
|
|
57
|
+
opacity: 0;
|
|
58
|
+
transform: translateX(-100px) translateY(50px);
|
|
59
|
+
}
|
|
60
|
+
.jos-fade-right-down {
|
|
61
|
+
opacity: 0;
|
|
62
|
+
transform: translateX(-100px) translateY(-50px);
|
|
63
|
+
}
|
|
64
|
+
.jos-fade-left-up {
|
|
65
|
+
opacity: 0;
|
|
66
|
+
transform: translateX(100px) translateY(50px);
|
|
67
|
+
}
|
|
68
|
+
.jos-fade-left-down {
|
|
69
|
+
opacity: 0;
|
|
70
|
+
transform: translateX(100px) translateY(-50px);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* slide */
|
|
74
|
+
|
|
75
|
+
.jos-slide,
|
|
76
|
+
.jos-slide-right {
|
|
77
|
+
transform: translateX(-100px);
|
|
78
|
+
}
|
|
79
|
+
.jos-slide-left {
|
|
80
|
+
transform: translateX(100px);
|
|
81
|
+
}
|
|
82
|
+
.jos-slide-up {
|
|
83
|
+
transform: translateY(100px);
|
|
84
|
+
}
|
|
85
|
+
.jos-slide-down {
|
|
86
|
+
transform: translateY(-100px);
|
|
87
|
+
}
|
|
88
|
+
.jos-slide-right-up {
|
|
89
|
+
transform: translateX(-100px) translateY(100px);
|
|
90
|
+
}
|
|
91
|
+
.jos-slide-right-down {
|
|
92
|
+
transform: translateX(-100px) translateY(-100px);
|
|
93
|
+
}
|
|
94
|
+
.jos-slide-left-up {
|
|
95
|
+
transform: translateX(100px) translateY(100px);
|
|
96
|
+
}
|
|
97
|
+
.jos-slide-left-down {
|
|
98
|
+
transform: translateX(100px) translateY(-100px);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* zoom out */
|
|
102
|
+
.jos-zoom,
|
|
103
|
+
.jos-zoom-out {
|
|
104
|
+
opacity: 0;
|
|
105
|
+
transform: scale(0.8);
|
|
106
|
+
}
|
|
107
|
+
.jos-zoom-out-right,
|
|
108
|
+
.jos-zoom-right {
|
|
109
|
+
opacity: 0;
|
|
110
|
+
transform: scale(0.8) translate3d(-100px, 0px, -100px);
|
|
111
|
+
}
|
|
112
|
+
.jos-zoom-out-left,
|
|
113
|
+
.jos-zoom-left {
|
|
114
|
+
opacity: 0;
|
|
115
|
+
transform: scale(0.8) translate3d(100px, 0px, -100px);
|
|
116
|
+
}
|
|
117
|
+
.jos-zoom-out-down,
|
|
118
|
+
.jos-zoom-down {
|
|
119
|
+
opacity: 0;
|
|
120
|
+
transform: scale(0.8) translate3d(0px, -100px, 0px);
|
|
121
|
+
}
|
|
122
|
+
.jos-zoom-out-up,
|
|
123
|
+
.jos-zoom-up {
|
|
124
|
+
opacity: 0;
|
|
125
|
+
transform: scale(0.8) translate3d(0px, 100px, 0px);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* grow */
|
|
129
|
+
.jos-grow {
|
|
130
|
+
transform: scale(0);
|
|
131
|
+
}
|
|
132
|
+
.jos-grow-right {
|
|
133
|
+
transform: scale(0) translate3d(-100px, 0px, -100px);
|
|
134
|
+
}
|
|
135
|
+
.jos-grow-left {
|
|
136
|
+
transform: scale(0) translate3d(100px, 0px, -100px);
|
|
137
|
+
}
|
|
138
|
+
.jos-grow-down {
|
|
139
|
+
transform: scale(0) translate3d(0px, -100px, 0px);
|
|
140
|
+
}
|
|
141
|
+
.jos-grow-up {
|
|
142
|
+
transform: scale(0) translate3d(0px, 100px, 0px);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* zoom in */
|
|
146
|
+
.jos-zoom-in {
|
|
147
|
+
opacity: 0;
|
|
148
|
+
transform: scale(1.1);
|
|
149
|
+
}
|
|
150
|
+
.jos-zoom-in-down {
|
|
151
|
+
opacity: 0;
|
|
152
|
+
transform: scale(1.1) translate3d(0px, -100px, 0px);
|
|
153
|
+
}
|
|
154
|
+
.jos-zoom-in-up {
|
|
155
|
+
opacity: 0;
|
|
156
|
+
transform: scale(1.1) translate3d(0px, 100px, 0px);
|
|
157
|
+
}
|
|
158
|
+
.jos-zoom-in-right {
|
|
159
|
+
opacity: 0;
|
|
160
|
+
transform: scale(1.1) translate3d(-100px, 0px, -100px);
|
|
161
|
+
}
|
|
162
|
+
.jos-zoom-in-left {
|
|
163
|
+
opacity: 0;
|
|
164
|
+
transform: scale(1.1) translate3d(100px, 0px, -100px);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* shrink */
|
|
168
|
+
.jos-shrink {
|
|
169
|
+
transform: scale(1.4);
|
|
170
|
+
}
|
|
171
|
+
.jos-shrink-right {
|
|
172
|
+
transform: scale(1.4) translate3d(-100px, 0px, -100px);
|
|
173
|
+
}
|
|
174
|
+
.jos-shrink-left {
|
|
175
|
+
transform: scale(1.4) translate3d(100px, 0px, -100px);
|
|
176
|
+
}
|
|
177
|
+
.jos-shrink-down {
|
|
178
|
+
transform: scale(1.4) translate3d(0px, -100px, 0px);
|
|
179
|
+
}
|
|
180
|
+
.jos-shrink-up {
|
|
181
|
+
transform: scale(1.4) translate3d(0px, 100px, 0px);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* flip */
|
|
185
|
+
.jos-flip,
|
|
186
|
+
.jos-flip-right {
|
|
187
|
+
transform: perspective(2500px) rotateY(-100deg);
|
|
188
|
+
opacity: 0;
|
|
189
|
+
}
|
|
190
|
+
.jos-flip-left {
|
|
191
|
+
transform: perspective(2500px) rotateY(100deg);
|
|
192
|
+
opacity: 0;
|
|
193
|
+
}
|
|
194
|
+
.jos-flip-up {
|
|
195
|
+
opacity: 0;
|
|
196
|
+
transform: perspective(2500px) rotateX(-100deg);
|
|
197
|
+
}
|
|
198
|
+
.jos-flip-down {
|
|
199
|
+
opacity: 0;
|
|
200
|
+
transform: perspective(2500px) rotateX(100deg);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* rotate */
|
|
204
|
+
.jos-rotate,
|
|
205
|
+
.jos-rotate-right {
|
|
206
|
+
opacity: 0;
|
|
207
|
+
transform: rotate(-180deg);
|
|
208
|
+
}
|
|
209
|
+
.jos-rotate-left {
|
|
210
|
+
opacity: 0;
|
|
211
|
+
transform: rotate(180deg);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/* spin */
|
|
215
|
+
.jos-spin,
|
|
216
|
+
.jos-spin-right {
|
|
217
|
+
opacity: 0;
|
|
218
|
+
transform: rotate(-180deg) scale(0);
|
|
219
|
+
}
|
|
220
|
+
.jos-spin-left {
|
|
221
|
+
opacity: 0;
|
|
222
|
+
transform: rotate(180deg) scale(0);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* revolve */
|
|
226
|
+
.jos-revolve,
|
|
227
|
+
.jos-revolve-right {
|
|
228
|
+
opacity: 0;
|
|
229
|
+
transform: rotate(-360deg) scale(0);
|
|
230
|
+
}
|
|
231
|
+
.jos-revolve-left {
|
|
232
|
+
opacity: 0;
|
|
233
|
+
transform: rotate(360deg) scale(0);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/* stretch */
|
|
237
|
+
.jos-stretch {
|
|
238
|
+
opacity: 0;
|
|
239
|
+
transform: scaleX(0);
|
|
240
|
+
}
|
|
241
|
+
.jos-stretch-vertical {
|
|
242
|
+
opacity: 0;
|
|
243
|
+
transform: scaleY(0);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/* timing function attribute */
|
|
247
|
+
[data-jos_timing_function="ease"] {
|
|
248
|
+
transition-timing-function: ease !important;
|
|
249
|
+
}
|
|
250
|
+
[data-jos_timing_function="ease-in"] {
|
|
251
|
+
transition-timing-function: ease-in !important;
|
|
252
|
+
}
|
|
253
|
+
[data-jos_timing_function="ease-out"] {
|
|
254
|
+
transition-timing-function: ease-out !important;
|
|
255
|
+
}
|
|
256
|
+
[data-jos_timing_function="ease-in-out"] {
|
|
257
|
+
transition-timing-function: ease-in-out !important;
|
|
258
|
+
}
|
|
259
|
+
[data-jos_timing_function="linear"] {
|
|
260
|
+
transition-timing-function: linear !important;
|
|
261
|
+
}
|
|
262
|
+
[data-jos_timing_function="cubic-bezier"] {
|
|
263
|
+
transition-timing-function: cubic-bezier(0.1, 0.7, 1, 0.1) !important;
|
|
264
|
+
}
|
|
265
|
+
[data-jos_timing_function="step-start"] {
|
|
266
|
+
transition-timing-function: step-start !important;
|
|
267
|
+
}
|
|
268
|
+
[data-jos_timing_function="step-end"] {
|
|
269
|
+
transition-timing-function: step-end !important;
|
|
270
|
+
}
|
|
271
|
+
[data-jos_timing_function="steps"] {
|
|
272
|
+
transition-timing-function: steps(5, end) !important;
|
|
273
|
+
}
|
|
274
|
+
[data-jos_timing_function="frames"] {
|
|
275
|
+
transition-timing-function: frames(5) !important;
|
|
276
|
+
}
|
|
277
|
+
[data-jos_timing_function="initial"] {
|
|
278
|
+
transition-timing-function: initial !important;
|
|
279
|
+
}
|
|
280
|
+
[data-jos_timing_function="inherit"] {
|
|
281
|
+
transition-timing-function: inherit !important;
|
|
282
|
+
}
|
|
283
|
+
[data-jos_timing_function="unset"] {
|
|
284
|
+
transition-timing-function: unset !important;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/* duration attribute */
|
|
288
|
+
[data-jos_duration="0"] {
|
|
289
|
+
transition-duration: 0s !important;
|
|
290
|
+
}
|
|
291
|
+
[data-jos_duration="0.1"] {
|
|
292
|
+
transition-duration: 0.1s !important;
|
|
293
|
+
}
|
|
294
|
+
[data-jos_duration="0.2"] {
|
|
295
|
+
transition-duration: 0.2s !important;
|
|
296
|
+
}
|
|
297
|
+
[data-jos_duration="0.3"] {
|
|
298
|
+
transition-duration: 0.3s !important;
|
|
299
|
+
}
|
|
300
|
+
[data-jos_duration="0.4"] {
|
|
301
|
+
transition-duration: 0.4s !important;
|
|
302
|
+
}
|
|
303
|
+
[data-jos_duration="0.5"] {
|
|
304
|
+
transition-duration: 0.5s !important;
|
|
305
|
+
}
|
|
306
|
+
[data-jos_duration="0.6"] {
|
|
307
|
+
transition-duration: 0.6s !important;
|
|
308
|
+
}
|
|
309
|
+
[data-jos_duration="0.7"] {
|
|
310
|
+
transition-duration: 0.7s !important;
|
|
311
|
+
}
|
|
312
|
+
[data-jos_duration="0.8"] {
|
|
313
|
+
transition-duration: 0.8s !important;
|
|
314
|
+
}
|
|
315
|
+
[data-jos_duration="0.9"] {
|
|
316
|
+
transition-duration: 0.9s !important;
|
|
317
|
+
}
|
|
318
|
+
[data-jos_duration="1"] {
|
|
319
|
+
transition-duration: 1s !important;
|
|
320
|
+
}
|
|
321
|
+
[data-jos_duration="2"] {
|
|
322
|
+
transition-duration: 2s !important;
|
|
323
|
+
}
|
|
324
|
+
[data-jos_duration="3"] {
|
|
325
|
+
transition-duration: 3s !important;
|
|
326
|
+
}
|
|
327
|
+
[data-jos_duration="4"] {
|
|
328
|
+
transition-duration: 4s !important;
|
|
329
|
+
}
|
|
330
|
+
[data-jos_duration="5"] {
|
|
331
|
+
transition: 5s !important;
|
|
332
|
+
}
|
|
333
|
+
[data-jos_duration="6"] {
|
|
334
|
+
transition-duration: 1s !important;
|
|
335
|
+
}
|
|
336
|
+
[data-jos_duration="7"] {
|
|
337
|
+
transition-duration: 2s !important;
|
|
338
|
+
}
|
|
339
|
+
[data-jos_duration="8"] {
|
|
340
|
+
transition-duration: 3s !important;
|
|
341
|
+
}
|
|
342
|
+
[data-jos_duration="9"] {
|
|
343
|
+
transition-duration: 4s !important;
|
|
344
|
+
}
|
|
345
|
+
[data-jos_duration="10"] {
|
|
346
|
+
transition: 5s !important;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/* Delay Attribute */
|
|
350
|
+
[data-jos_delay="0"] {
|
|
351
|
+
transition-delay: 0s !important;
|
|
352
|
+
}
|
|
353
|
+
[data-jos_delay="0.1"] {
|
|
354
|
+
transition-delay: 0.1s !important;
|
|
355
|
+
}
|
|
356
|
+
[data-jos_delay="0.2"] {
|
|
357
|
+
transition-delay: 0.2s !important;
|
|
358
|
+
}
|
|
359
|
+
[data-jos_delay="0.3"] {
|
|
360
|
+
transition-delay: 0.3s !important;
|
|
361
|
+
}
|
|
362
|
+
[data-jos_delay="0.4"] {
|
|
363
|
+
transition-delay: 0.4s !important;
|
|
364
|
+
}
|
|
365
|
+
[data-jos_delay="0.5"] {
|
|
366
|
+
transition-delay: 0.5s !important;
|
|
367
|
+
}
|
|
368
|
+
[data-jos_delay="0.6"] {
|
|
369
|
+
transition-delay: 0.6s !important;
|
|
370
|
+
}
|
|
371
|
+
[data-jos_delay="0.7"] {
|
|
372
|
+
transition-delay: 0.7s !important;
|
|
373
|
+
}
|
|
374
|
+
[data-jos_delay="0.8"] {
|
|
375
|
+
transition-delay: 0.8s !important;
|
|
376
|
+
}
|
|
377
|
+
[data-jos_delay="0.9"] {
|
|
378
|
+
transition-delay: 0.9s !important;
|
|
379
|
+
}
|
|
380
|
+
[data-jos_delay="1"] {
|
|
381
|
+
transition-delay: 1s !important;
|
|
382
|
+
}
|
|
383
|
+
[data-jos_delay="2"] {
|
|
384
|
+
transition-delay: 2s !important;
|
|
385
|
+
}
|
|
386
|
+
[data-jos_delay="3"] {
|
|
387
|
+
transition-delay: 3s !important;
|
|
388
|
+
}
|
|
389
|
+
[data-jos_delay="4"] {
|
|
390
|
+
transition-delay: 4s !important;
|
|
391
|
+
}
|
|
392
|
+
[data-jos_delay="5"] {
|
|
393
|
+
transition-delay: 5s !important;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/* Playable animations */
|
|
397
|
+
|
|
398
|
+
.jos-slide-play,
|
|
399
|
+
.jos-slide-horizontal-play {
|
|
400
|
+
transition: 1s;
|
|
401
|
+
animation: jos-slide-play 0.7s ease-in-out infinite;
|
|
402
|
+
animation-direction: alternate-reverse;
|
|
403
|
+
}
|
|
404
|
+
@keyframes jos-slide-play {
|
|
405
|
+
0% {
|
|
406
|
+
transform: translateX(-100px);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
100% {
|
|
410
|
+
transform: translateX(100px);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.jos-slide-vertical-play {
|
|
415
|
+
animation: jos-slide-vertical-play 0.7s ease-in-out infinite;
|
|
416
|
+
animation-direction: alternate-reverse;
|
|
417
|
+
}
|
|
418
|
+
@keyframes jos-slide-vertical-play {
|
|
419
|
+
0% {
|
|
420
|
+
transform: translateY(-100px);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
100% {
|
|
424
|
+
transform: translateY(100px);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.jos-zoom-in-play,
|
|
429
|
+
.jos-pulse-play {
|
|
430
|
+
animation: jos-zoom-in-play 1s infinite;
|
|
431
|
+
animation-direction: alternate;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
@keyframes jos-zoom-in-play {
|
|
435
|
+
0% {
|
|
436
|
+
transform: scale(1);
|
|
437
|
+
opacity: 0;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
100% {
|
|
441
|
+
opacity: 1;
|
|
442
|
+
transform: scale(0.8);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.jos-zoom-play,
|
|
447
|
+
.jos-zoom-out-play,
|
|
448
|
+
.jos-pulse-out-play {
|
|
449
|
+
animation: jos-zoom-play 0.5s linear infinite;
|
|
450
|
+
animation-direction: alternate;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
@keyframes jos-zoom-play {
|
|
454
|
+
0% {
|
|
455
|
+
transform: scale(1);
|
|
456
|
+
opacity: 0;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
100% {
|
|
460
|
+
opacity: 1;
|
|
461
|
+
transform: scale(1.1);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
.jos-flip-play {
|
|
466
|
+
animation: jos-flip-play 0.7s infinite;
|
|
467
|
+
animation-direction: alternate;
|
|
468
|
+
}
|
|
469
|
+
@keyframes jos-flip-play {
|
|
470
|
+
0% {
|
|
471
|
+
transform: rotateY(0deg);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
100% {
|
|
475
|
+
transform: rotateY(180deg);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
.jos-rotate-play {
|
|
480
|
+
animation: jos-rotate-play 1s linear forwards infinite;
|
|
481
|
+
border-radius: 0%;
|
|
482
|
+
animation-direction: alternate-reverse;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
@keyframes jos-rotate-play {
|
|
486
|
+
0% {
|
|
487
|
+
transform: rotate(0deg);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
100% {
|
|
491
|
+
transform: rotate(360deg);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
.jos-spin-play {
|
|
496
|
+
animation: jos-spin-play 1.5s infinite;
|
|
497
|
+
animation-direction: alternate;
|
|
498
|
+
}
|
|
499
|
+
@keyframes jos-spin-play {
|
|
500
|
+
0% {
|
|
501
|
+
transform: rotate(0deg);
|
|
502
|
+
opacity: 0;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
100% {
|
|
506
|
+
transform: rotate(360deg);
|
|
507
|
+
opacity: 1;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
.jos-revolve-play {
|
|
512
|
+
animation: jos-revolve-play 1.5s infinite;
|
|
513
|
+
animation-direction: alternate;
|
|
514
|
+
}
|
|
515
|
+
@keyframes jos-revolve-play {
|
|
516
|
+
0% {
|
|
517
|
+
transform: rotate(0deg);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
100% {
|
|
521
|
+
transform: rotate(360deg);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
.jos-grow-play,
|
|
526
|
+
.jos-shrink-play {
|
|
527
|
+
animation: jos-grow-play 1s infinite;
|
|
528
|
+
animation-direction: alternate;
|
|
529
|
+
}
|
|
530
|
+
@keyframes jos-grow-play {
|
|
531
|
+
0% {
|
|
532
|
+
transform: scale(0);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
100% {
|
|
536
|
+
transform: scale(1);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.jos-shrink-play {
|
|
541
|
+
animation-direction: alternate-reverse;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
.jos-stretch-play {
|
|
545
|
+
animation: jos-stretch-play 0.7s infinite;
|
|
546
|
+
animation-direction: alternate;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
@keyframes jos-stretch-play {
|
|
550
|
+
0% {
|
|
551
|
+
transform: scaleX(1);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
100% {
|
|
555
|
+
transform: scaleX(0);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
.jos-stretch-vertical-play {
|
|
560
|
+
animation: jos-stretch-vertical-play 0.7s infinite;
|
|
561
|
+
animation-direction: alternate-reverse;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
@keyframes jos-stretch-vertical-play {
|
|
565
|
+
0% {
|
|
566
|
+
transform: scaleY(1);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
100% {
|
|
570
|
+
transform: scaleY(0);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.jos-fade-play {
|
|
575
|
+
animation: jos-fade-play 0.8s infinite;
|
|
576
|
+
animation-direction: alternate;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
@keyframes jos-fade-play {
|
|
580
|
+
0% {
|
|
581
|
+
opacity: 0;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
100% {
|
|
585
|
+
opacity: 1;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
.jos-fade-horizontal-play {
|
|
590
|
+
animation: jos-fade-horizontal-play 1s infinite;
|
|
591
|
+
animation-direction: alternate-reverse;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
@keyframes jos-fade-horizontal-play {
|
|
595
|
+
0% {
|
|
596
|
+
opacity: 0;
|
|
597
|
+
transform: translateX(100px);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
100% {
|
|
601
|
+
opacity: 1;
|
|
602
|
+
transform: translateX(-100px);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
.jos-fade-vertical-play {
|
|
607
|
+
animation: jos-fade-vertical-play 1s infinite;
|
|
608
|
+
animation-direction: alternate-reverse;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
@keyframes jos-fade-vertical-play {
|
|
612
|
+
0% {
|
|
613
|
+
opacity: 0;
|
|
614
|
+
transform: translateY(100px);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
100% {
|
|
618
|
+
opacity: 1;
|
|
619
|
+
transform: translateY(-100px);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
.jos-blink-play {
|
|
624
|
+
animation: jos-blink-play 1s steps(1, end) infinite;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
@keyframes jos-blink-play {
|
|
628
|
+
0% {
|
|
629
|
+
opacity: 1;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
50% {
|
|
633
|
+
opacity: 0;
|
|
634
|
+
}
|
|
635
|
+
}
|
package/dev/jos.js
ADDED
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
class jos {
|
|
2
|
+
default_once = false;
|
|
3
|
+
default_animation = "fade";
|
|
4
|
+
default_animationinverse = undefined;
|
|
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 = undefined;
|
|
12
|
+
default_scrolldirection = undefined;
|
|
13
|
+
default_passive = true;
|
|
14
|
+
default_mirror = undefined;
|
|
15
|
+
|
|
16
|
+
debug = false;
|
|
17
|
+
disable = false;
|
|
18
|
+
|
|
19
|
+
static version = "0.8.7 (Development)";
|
|
20
|
+
static author = "Jesvi Jonathan";
|
|
21
|
+
static github = "https://github.com/jesvijonathan/JOS-Animation-Library";
|
|
22
|
+
|
|
23
|
+
options = {};
|
|
24
|
+
jos_stylesheet = undefined;
|
|
25
|
+
boxes = undefined;
|
|
26
|
+
observers = [];
|
|
27
|
+
scrollEnter = [];
|
|
28
|
+
|
|
29
|
+
constructor() {}
|
|
30
|
+
|
|
31
|
+
version() {
|
|
32
|
+
console.log(`JOS: Javascript On Scroll Animation Library
|
|
33
|
+
- Version: ${jos.version}
|
|
34
|
+
- Author: ${jos.author}
|
|
35
|
+
- Github: ${jos.github}\n`);
|
|
36
|
+
}
|
|
37
|
+
//debugger = () => null;
|
|
38
|
+
debugger(type = 0) {
|
|
39
|
+
if (type == 0 && this.debugMode) {
|
|
40
|
+
this.version();
|
|
41
|
+
console.log(`JOS Settings:
|
|
42
|
+
- animation: ${this.default_animation}
|
|
43
|
+
- once: ${this.default_once}
|
|
44
|
+
- animationinverse: ${this.default_animationinverse}
|
|
45
|
+
- timingFunction: ${this.default_timingFunction}
|
|
46
|
+
- duration: ${this.default_duration}
|
|
47
|
+
- delay: ${this.default_delay}
|
|
48
|
+
- threshold: ${this.default_threshold}
|
|
49
|
+
- startVisible: ${this.default_startVisible}
|
|
50
|
+
- scrolldirection: ${this.default_scrolldirection}
|
|
51
|
+
- intersectionRatio: ${this.default_intersectionRatio}
|
|
52
|
+
- rootMargin: ${this.default_rootMargin}
|
|
53
|
+
- disable: ${this.disable}
|
|
54
|
+
- debugMode: ${this.debugMode}\n`);
|
|
55
|
+
}
|
|
56
|
+
console.log("JOS Initialized:\n\n");
|
|
57
|
+
if ((type == 1 || type == 0) && this.debugMode) {
|
|
58
|
+
console.log(this.boxes || "No Elements Found");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
callbackRouter_anchor = (entries, observer) => {
|
|
63
|
+
let entry = entries[0];
|
|
64
|
+
let parentTarget = entry.target;
|
|
65
|
+
let elem = document.querySelectorAll(
|
|
66
|
+
"[data-jos_anchor='#" + parentTarget.id + "']"
|
|
67
|
+
);
|
|
68
|
+
elem.forEach((target) => {
|
|
69
|
+
let target_jos_animation = target.dataset.jos_animation;
|
|
70
|
+
let target_jos_animationinverse = target.dataset.jos_animationinverse;
|
|
71
|
+
let scroll_dir = 1;
|
|
72
|
+
if (entry.isIntersecting) {
|
|
73
|
+
if (target.dataset.jos_counter != undefined) {
|
|
74
|
+
let counter_value = parseInt(target.dataset.jos_counter);
|
|
75
|
+
counter_value++;
|
|
76
|
+
target.dataset.jos_counter = counter_value;
|
|
77
|
+
}
|
|
78
|
+
if (target_jos_animation) {
|
|
79
|
+
target.classList.remove("jos-" + target_jos_animation);
|
|
80
|
+
if (target.dataset.jos_invoke != undefined) {
|
|
81
|
+
window[target.dataset.jos_invoke](target);
|
|
82
|
+
}
|
|
83
|
+
if (
|
|
84
|
+
target.dataset.jos_once != undefined ||
|
|
85
|
+
target.dataset.jos_once != "false"
|
|
86
|
+
) {
|
|
87
|
+
if (target.dataset.jos_once == "true") {
|
|
88
|
+
observer.unobserve(target);
|
|
89
|
+
} else if (target.dataset.jos_counter >= target.dataset.jos_once) {
|
|
90
|
+
observer.unobserve(target);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (target_jos_animationinverse != undefined) {
|
|
94
|
+
target.classList.add("jos-" + target_jos_animationinverse);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
if (
|
|
99
|
+
target.dataset.jos_scrolldirection === undefined ||
|
|
100
|
+
(scroll_dir === 1 && target.dataset.jos_scrolldirection === "down") ||
|
|
101
|
+
(scroll_dir === 0 && target.dataset.jos_scrolldirection === "up") ||
|
|
102
|
+
target.dataset.jos_scrolldirection === "none"
|
|
103
|
+
) {
|
|
104
|
+
target.classList.add("jos-" + target_jos_animation);
|
|
105
|
+
if (target.dataset.jos_invoke_out !== undefined) {
|
|
106
|
+
window[target.dataset.jos_invoke_out](target);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// var box = target;
|
|
114
|
+
// console.log(box);
|
|
115
|
+
// const rootmargin = " 0% 0% -30% 0%";
|
|
116
|
+
callbackScroller = (scl) => {
|
|
117
|
+
const defaultRootMargin = this.default_rootMargin;
|
|
118
|
+
let wh = window.innerHeight;
|
|
119
|
+
|
|
120
|
+
const updateBox = (box) => {
|
|
121
|
+
const rootMargin = box.dataset.jos_rootmargin || defaultRootMargin;
|
|
122
|
+
const rootMarginValues = rootMargin.split(" ").map(parseFloat);
|
|
123
|
+
const topMargin = (wh * rootMarginValues[0]) / 100;
|
|
124
|
+
const bottomMargin = (wh * rootMarginValues[2]) / 100;
|
|
125
|
+
|
|
126
|
+
box.jos = {
|
|
127
|
+
rootMargin,
|
|
128
|
+
rootMarginValues,
|
|
129
|
+
topMargin,
|
|
130
|
+
bottomMargin,
|
|
131
|
+
};
|
|
132
|
+
const elementRect = box.getBoundingClientRect();
|
|
133
|
+
const elementTop = elementRect.top - box.jos.topMargin;
|
|
134
|
+
const elementBottom = elementRect.bottom - box.jos.bottomMargin;
|
|
135
|
+
|
|
136
|
+
const windowScrollProgress = elementRect.top / wh;
|
|
137
|
+
|
|
138
|
+
const rootScrollProgress =
|
|
139
|
+
elementTop / (wh - box.jos.topMargin - box.jos.bottomMargin);
|
|
140
|
+
|
|
141
|
+
let scrollProgress = 0;
|
|
142
|
+
|
|
143
|
+
if (rootScrollProgress < 0) {
|
|
144
|
+
scrollProgress = 0;
|
|
145
|
+
} else if (rootScrollProgress > 100) {
|
|
146
|
+
scrollProgress = 1;
|
|
147
|
+
} else {
|
|
148
|
+
scrollProgress = rootScrollProgress;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
box.jos = {
|
|
152
|
+
elementRect,
|
|
153
|
+
elementTop,
|
|
154
|
+
elementBottom,
|
|
155
|
+
windowScrollProgress,
|
|
156
|
+
rootScrollProgress,
|
|
157
|
+
scrollProgress,
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
window[box.dataset.jos_scroll](box);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
document.onscroll = (e) => {
|
|
164
|
+
scl.forEach(updateBox);
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// window["jos_scroll_" + box.id](obj);
|
|
169
|
+
callbackRouter = (entries, observer, type = 1) => {
|
|
170
|
+
if (this.disable == true) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
let entry = entries[0];
|
|
174
|
+
let target = entry.target;
|
|
175
|
+
let target_jos_animation = target.dataset.jos_animation;
|
|
176
|
+
let target_jos_animationinverse = target.dataset.jos_animationinverse;
|
|
177
|
+
|
|
178
|
+
let scroll_dir = 1;
|
|
179
|
+
if (entry.boundingClientRect.top < 0) {
|
|
180
|
+
scroll_dir = 0;
|
|
181
|
+
} else {
|
|
182
|
+
scroll_dir = 1;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (entry.isIntersecting) {
|
|
186
|
+
if (
|
|
187
|
+
target.dataset.jos_scroll != "false" &&
|
|
188
|
+
target.dataset.jos_scroll != undefined
|
|
189
|
+
) {
|
|
190
|
+
this.scrollEnter.push(target);
|
|
191
|
+
this.callbackScroller(this.scrollEnter);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (target.dataset.jos_counter != undefined) {
|
|
195
|
+
let counter_value = parseInt(target.dataset.jos_counter);
|
|
196
|
+
counter_value++;
|
|
197
|
+
target.dataset.jos_counter = counter_value;
|
|
198
|
+
}
|
|
199
|
+
if (target.dataset.jos_mirror == "false") {
|
|
200
|
+
target.classList.remove("jos-no-mirror");
|
|
201
|
+
}
|
|
202
|
+
if (target_jos_animation) {
|
|
203
|
+
target.classList.remove("jos-" + target_jos_animation);
|
|
204
|
+
if (target.dataset.jos_invoke != undefined) {
|
|
205
|
+
window[target.dataset.jos_invoke](target);
|
|
206
|
+
}
|
|
207
|
+
if (
|
|
208
|
+
target.dataset.jos_once != undefined ||
|
|
209
|
+
target.dataset.jos_once != "false"
|
|
210
|
+
) {
|
|
211
|
+
if (target.dataset.jos_once == "true") {
|
|
212
|
+
observer.unobserve(target);
|
|
213
|
+
} else if (target.dataset.jos_counter >= target.dataset.jos_once) {
|
|
214
|
+
observer.unobserve(target);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (target_jos_animationinverse != undefined) {
|
|
219
|
+
target.classList.add("jos-" + target_jos_animationinverse);
|
|
220
|
+
}
|
|
221
|
+
} else {
|
|
222
|
+
if (
|
|
223
|
+
target.dataset.jos_scrolldirection === undefined ||
|
|
224
|
+
(scroll_dir === 1 && target.dataset.jos_scrolldirection === "down") ||
|
|
225
|
+
(scroll_dir === 0 && target.dataset.jos_scrolldirection === "up") ||
|
|
226
|
+
target.dataset.jos_scrolldirection === "none"
|
|
227
|
+
) {
|
|
228
|
+
target.classList.toggle(
|
|
229
|
+
"jos-no-mirror",
|
|
230
|
+
target.dataset.jos_mirror == "false"
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
target.classList.add("jos-" + target_jos_animation);
|
|
234
|
+
if (target_jos_animationinverse != undefined) {
|
|
235
|
+
target.classList.remove("jos-" + target_jos_animationinverse);
|
|
236
|
+
}
|
|
237
|
+
if (target.dataset.jos_invoke_out !== undefined) {
|
|
238
|
+
window[target.dataset.jos_invoke_out](target);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (
|
|
242
|
+
target.dataset.jos_scroll != "false" &&
|
|
243
|
+
target.dataset.jos_scroll != undefined
|
|
244
|
+
) {
|
|
245
|
+
this.scrollEnter = this.scrollEnter.filter(
|
|
246
|
+
(item) => item.id !== target.id
|
|
247
|
+
);
|
|
248
|
+
this.callbackScroller(this.scrollEnter);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
animationInit() {
|
|
254
|
+
let doit = [];
|
|
255
|
+
this.boxes.forEach((box) => {
|
|
256
|
+
let object_default_once = box.dataset.jos_once;
|
|
257
|
+
let object_default_animation =
|
|
258
|
+
box.dataset.jos_animation || this.default_animation;
|
|
259
|
+
let object_default_animationinverse = box.dataset.jos_animationinverse;
|
|
260
|
+
let object_default_timingFunction = box.dataset.jos_timingFunction;
|
|
261
|
+
let object_default_duration = box.dataset.jos_duration;
|
|
262
|
+
let object_default_delay = box.dataset.jos_delay;
|
|
263
|
+
let object_default_mirror = box.dataset.jos_mirror || this.default_mirror;
|
|
264
|
+
if (box.classList.contains("jos_disabled")) {
|
|
265
|
+
box.classList.remove("jos_disabled");
|
|
266
|
+
box.classList.add("jos");
|
|
267
|
+
}
|
|
268
|
+
if (
|
|
269
|
+
object_default_once &&
|
|
270
|
+
(object_default_once == "true" || /^\d+$/.test(object_default_once))
|
|
271
|
+
) {
|
|
272
|
+
box.setAttribute("data-jos_once", object_default_once);
|
|
273
|
+
} else {
|
|
274
|
+
box.setAttribute("data-jos_once", this.default_once ? "1" : "false");
|
|
275
|
+
}
|
|
276
|
+
box.setAttribute("data-jos_animation", object_default_animation);
|
|
277
|
+
if (object_default_animationinverse) {
|
|
278
|
+
box.setAttribute(
|
|
279
|
+
"data-jos_animationinverse",
|
|
280
|
+
object_default_animationinverse
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
if (object_default_timingFunction) {
|
|
284
|
+
box.setAttribute(
|
|
285
|
+
"data-jos_timingFunction",
|
|
286
|
+
object_default_timingFunction
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (object_default_mirror == "false") {
|
|
291
|
+
box.setAttribute("data-jos_mirror", object_default_mirror);
|
|
292
|
+
}
|
|
293
|
+
if (object_default_duration) {
|
|
294
|
+
box.setAttribute("data-jos_duration", object_default_duration);
|
|
295
|
+
}
|
|
296
|
+
if (object_default_delay) {
|
|
297
|
+
box.setAttribute("data-jos_delay", object_default_delay);
|
|
298
|
+
}
|
|
299
|
+
box.setAttribute("data-jos_counter", "0");
|
|
300
|
+
box.classList.add("jos-" + object_default_animation);
|
|
301
|
+
if (box.dataset.jos_startvisible || this.default_startVisible) {
|
|
302
|
+
doit.push(box);
|
|
303
|
+
}
|
|
304
|
+
if (this.default_scrolldirection) {
|
|
305
|
+
box.setAttribute(
|
|
306
|
+
"data-jos_scrolldirection",
|
|
307
|
+
this.default_scrolldirection
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
let rootMargin = [
|
|
311
|
+
box.dataset.jos_rootmargin_top || this.default_rootMargin.split(" ")[0],
|
|
312
|
+
box.dataset.jos_rootmargin_right ||
|
|
313
|
+
this.default_rootMargin.split(" ")[1],
|
|
314
|
+
box.dataset.jos_rootmargin_bottom ||
|
|
315
|
+
this.default_rootMargin.split(" ")[2],
|
|
316
|
+
box.dataset.jos_rootmargin_left ||
|
|
317
|
+
this.default_rootMargin.split(" ")[3],
|
|
318
|
+
]
|
|
319
|
+
.map((value) => {
|
|
320
|
+
const isNegative = value.startsWith("-");
|
|
321
|
+
return isNegative ? value.substring(1) : `-${value}`;
|
|
322
|
+
})
|
|
323
|
+
.join(" ");
|
|
324
|
+
|
|
325
|
+
// let rootMargin = " 10% 0% -30% 0%";
|
|
326
|
+
|
|
327
|
+
let box_observer = {
|
|
328
|
+
rootMargin,
|
|
329
|
+
threshold: this.default_threshold,
|
|
330
|
+
passive: this.default_passive,
|
|
331
|
+
};
|
|
332
|
+
if (box.dataset.jos_anchor) {
|
|
333
|
+
const observer = new IntersectionObserver(
|
|
334
|
+
this.callbackRouter_anchor,
|
|
335
|
+
box_observer
|
|
336
|
+
);
|
|
337
|
+
this.observers.push(observer);
|
|
338
|
+
observer.observe(
|
|
339
|
+
document.getElementById(box.dataset.jos_anchor.substring(1))
|
|
340
|
+
);
|
|
341
|
+
} else {
|
|
342
|
+
const observer = new IntersectionObserver(
|
|
343
|
+
this.callbackRouter,
|
|
344
|
+
box_observer
|
|
345
|
+
);
|
|
346
|
+
this.observers.push(observer);
|
|
347
|
+
observer.observe(box);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
setTimeout(() => {
|
|
351
|
+
doit.forEach((box) => {
|
|
352
|
+
let box_time = box.dataset.jos_startvisible;
|
|
353
|
+
setTimeout(() => {
|
|
354
|
+
if (box_time == "true") {
|
|
355
|
+
box_time = 0;
|
|
356
|
+
}
|
|
357
|
+
box.classList.remove("jos-" + box.dataset.jos_animation);
|
|
358
|
+
}, box_time || this.default_startVisible);
|
|
359
|
+
});
|
|
360
|
+
}, 100);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
animationUnset(state = 0) {
|
|
364
|
+
if (state != -1) {
|
|
365
|
+
this.boxes?.forEach((box) => {
|
|
366
|
+
box.classList.remove("jos");
|
|
367
|
+
box.classList.add("jos_disabled");
|
|
368
|
+
if (state == 0) {
|
|
369
|
+
box.classList.add("jos-" + box.dataset.jos_animation);
|
|
370
|
+
} else {
|
|
371
|
+
box.classList.remove("jos-" + box.dataset.jos_animation);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
this.observers?.forEach((observer) => observer.disconnect());
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
getStylesheet() {
|
|
379
|
+
const styleElement = document.createElement("style");
|
|
380
|
+
document.head.appendChild(styleElement);
|
|
381
|
+
|
|
382
|
+
const styleSheet = styleElement.sheet;
|
|
383
|
+
styleSheet.insertRule(
|
|
384
|
+
".jos-no-mirror" + " { transition: 0s forwards !important;}"
|
|
385
|
+
);
|
|
386
|
+
|
|
387
|
+
let s =
|
|
388
|
+
this.default_duration +
|
|
389
|
+
"s " +
|
|
390
|
+
this.default_timingFunction +
|
|
391
|
+
" " +
|
|
392
|
+
this.default_delay +
|
|
393
|
+
"s";
|
|
394
|
+
|
|
395
|
+
styleSheet.insertRule(
|
|
396
|
+
".jos {" +
|
|
397
|
+
("transition: opacity " + s + ", transform " + s) +
|
|
398
|
+
"display: block;" +
|
|
399
|
+
"}"
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
this.jos_stylesheet = styleSheet;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
getBoxes() {
|
|
406
|
+
this.boxes = undefined;
|
|
407
|
+
|
|
408
|
+
if (!this.boxes) {
|
|
409
|
+
this.boxes = document.querySelectorAll(".jos");
|
|
410
|
+
}
|
|
411
|
+
return this.boxes;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
getDefault(options = {}) {
|
|
415
|
+
let {
|
|
416
|
+
once,
|
|
417
|
+
animation,
|
|
418
|
+
animationinverse,
|
|
419
|
+
timingFunction,
|
|
420
|
+
threshold,
|
|
421
|
+
startVisible,
|
|
422
|
+
scrollDirection,
|
|
423
|
+
intersectionRatio,
|
|
424
|
+
duration,
|
|
425
|
+
mirror,
|
|
426
|
+
delay,
|
|
427
|
+
debugMode,
|
|
428
|
+
disable,
|
|
429
|
+
rootMargin,
|
|
430
|
+
rootMarginTop,
|
|
431
|
+
rootMarginBottom,
|
|
432
|
+
} = options;
|
|
433
|
+
this.default_once = once || this.default_once;
|
|
434
|
+
this.default_animation = animation || this.default_animation;
|
|
435
|
+
this.default_animationinverse = animationinverse || this.default_animation;
|
|
436
|
+
this.default_timingFunction = timingFunction || this.default_timingFunction;
|
|
437
|
+
this.default_threshold = threshold || this.default_threshold;
|
|
438
|
+
this.default_startVisible = startVisible || this.default_startVisible;
|
|
439
|
+
this.default_scrolldirection =
|
|
440
|
+
scrollDirection || this.default_scrolldirection;
|
|
441
|
+
this.default_intersectionRatio =
|
|
442
|
+
intersectionRatio || this.default_threshold;
|
|
443
|
+
this.default_duration = duration || this.default_duration;
|
|
444
|
+
this.default_delay = delay || this.default_delay;
|
|
445
|
+
this.debugMode = debugMode || this.debugMode;
|
|
446
|
+
this.disable = disable || this.disable;
|
|
447
|
+
this.default_rootMargin =
|
|
448
|
+
rootMargin ||
|
|
449
|
+
`${rootMarginTop || "-10%"} 0% ${rootMarginBottom || "-40%"} 0%`;
|
|
450
|
+
this.default_mirror = mirror || this.default_mirror;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
init(options = this.options) {
|
|
454
|
+
this.options = options;
|
|
455
|
+
this.getDefault(options);
|
|
456
|
+
this.getStylesheet();
|
|
457
|
+
this.getBoxes();
|
|
458
|
+
if (this.debugMode) {
|
|
459
|
+
this.debugger();
|
|
460
|
+
}
|
|
461
|
+
if (this.disable) {
|
|
462
|
+
this.stop();
|
|
463
|
+
} else {
|
|
464
|
+
this.start();
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
start(state = 0) {
|
|
469
|
+
// 0 - Normal/Full Start
|
|
470
|
+
// -1 - Resume with current state
|
|
471
|
+
if (state != -1) {
|
|
472
|
+
this.stop();
|
|
473
|
+
this.animationInit();
|
|
474
|
+
}
|
|
475
|
+
this.disable = false;
|
|
476
|
+
return "Started";
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
stop(state = 0) {
|
|
480
|
+
if (state == 1) {
|
|
481
|
+
state = 0;
|
|
482
|
+
} else if (state == 0) {
|
|
483
|
+
state = 1;
|
|
484
|
+
}
|
|
485
|
+
// 0 - Stop | final state | opacity 1
|
|
486
|
+
// 1 - Stop | blank | opacity 0
|
|
487
|
+
// -1 - Pause | final state of elements in viewport
|
|
488
|
+
this.disable = true;
|
|
489
|
+
if (state != -1) {
|
|
490
|
+
this.animationUnset(state);
|
|
491
|
+
}
|
|
492
|
+
return "Stopped";
|
|
493
|
+
}
|
|
494
|
+
refresh() {
|
|
495
|
+
this.animationUnset(-1);
|
|
496
|
+
this.boxes = undefined;
|
|
497
|
+
this.getBoxes();
|
|
498
|
+
this.animationInit();
|
|
499
|
+
this.debugger(1);
|
|
500
|
+
return "Refreshed";
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
destroy(state = 0) {
|
|
504
|
+
// 0 - dont remove stylesheet | To preseve state
|
|
505
|
+
// 1 - remove along with stylesheet & jos stylesheet reference
|
|
506
|
+
this.animationUnset(-1);
|
|
507
|
+
this.boxes = undefined;
|
|
508
|
+
this.observers = [];
|
|
509
|
+
if (state == 1) {
|
|
510
|
+
this.jos_stylesheet.disabled = true;
|
|
511
|
+
}
|
|
512
|
+
this.jos_stylesheet = undefined;
|
|
513
|
+
for (let prop in this) {
|
|
514
|
+
if (this.hasOwnProperty(prop) && typeof this[prop] !== "function") {
|
|
515
|
+
this[prop] = undefined;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
Object.setPrototypeOf(this, null);
|
|
519
|
+
return "JOS Instance Nuked";
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
const JOS = new jos();
|
|
523
|
+
|
|
524
|
+
if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
|
|
525
|
+
module.exports = JOS;
|
|
526
|
+
}
|
package/dev/scroll.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const updateScrollPercentage = function () {
|
|
2
|
+
const heightOfWindow = window.innerHeight,
|
|
3
|
+
contentScrolled = window.pageYOffset,
|
|
4
|
+
bodyHeight = document.body.offsetHeight,
|
|
5
|
+
percentage = document.querySelector("[data-scrollPercentage] .percentage");
|
|
6
|
+
percentageVal = document.querySelector("#percentage-value");
|
|
7
|
+
|
|
8
|
+
if (bodyHeight - contentScrolled <= heightOfWindow) {
|
|
9
|
+
percentageVal.textContent = percentage.style.width = "100%";
|
|
10
|
+
} else {
|
|
11
|
+
const total = bodyHeight - heightOfWindow,
|
|
12
|
+
got = contentScrolled,
|
|
13
|
+
percent = parseInt((got / total) * 100);
|
|
14
|
+
percentageVal.textContent = percentage.style.width = percent + "%";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
window.addEventListener("scroll", updateScrollPercentage);
|
package/dist/jos.js
CHANGED
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jos-animation",
|
|
3
|
-
"version": "0.8.1",
|
|
3
|
+
"version": "0.8.7-beta.1",
|
|
4
4
|
"description": "An animation library package to instantly add beautiful/professional looking animation to your website",
|
|
5
5
|
"author": "Jesvi Jonathan",
|
|
6
|
-
"
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/*.{css,js}",
|
|
8
|
+
"dev/*.{css,js}"
|
|
9
|
+
],
|
|
10
|
+
"main": "dev/jos.js",
|
|
7
11
|
"repository": {
|
|
8
12
|
"type": "git",
|
|
9
13
|
"url": "git+https://github.com/jesvijonathan/JOS-Animation-Library.git"
|
|
10
14
|
},
|
|
11
|
-
"files": [
|
|
12
|
-
"dist/*.{css,js}"
|
|
13
|
-
],
|
|
14
15
|
"keywords": [
|
|
15
16
|
"jos",
|
|
16
17
|
"on-scroll",
|
|
@@ -30,5 +31,5 @@
|
|
|
30
31
|
"bugs": {
|
|
31
32
|
"url": "https://github.com/jesvijonathan/JOS-Animation-Library/issues"
|
|
32
33
|
},
|
|
33
|
-
"homepage": "https://github.
|
|
34
|
+
"homepage": "https://jesvijonathan.github.io/JOS-Animation-Library/"
|
|
34
35
|
}
|