nodality 1.0.0-beta.7 → 1.0.0-beta.8
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/dist/appleanim.cjs.js +1 -0
- package/dist/appleanim.esm.js +1 -0
- package/dist/betaMobileBar.esm.js +1 -1
- package/dist/bundle.umd.js +1 -1
- package/dist/finalresult.esm.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/multiswitchers.esm.js +1 -1
- package/dist/stacker.cjs.js +1 -0
- package/dist/stacker.esm.js +1 -0
- package/dist/transformanim.cjs.js +1 -0
- package/dist/transformanim.esm.js +1 -0
- package/layout/index.js +12 -1
- package/lib/AppleAnim.js +789 -0
- package/lib/Stacker.js +36 -0
- package/lib/TransformAnim.js +514 -0
- package/package.json +1 -1
package/lib/AppleAnim.js
ADDED
|
@@ -0,0 +1,789 @@
|
|
|
1
|
+
|
|
2
|
+
class KeyframeAnim {
|
|
3
|
+
constructor(data) {
|
|
4
|
+
this.fromFirstImageFlag = false;
|
|
5
|
+
this.flag = 0;
|
|
6
|
+
this.flagValue = data.flagValue;
|
|
7
|
+
this.data = data;
|
|
8
|
+
this.mask = data.mask; // overwrites method
|
|
9
|
+
this.maskData = data.maskData;
|
|
10
|
+
this.id = data.id;
|
|
11
|
+
|
|
12
|
+
this.halfHeight = data.halfHeight;
|
|
13
|
+
if (this.data.type === undefined){
|
|
14
|
+
this.type = "default";
|
|
15
|
+
} else {
|
|
16
|
+
this.type = this.data.type;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
this.stickData = data.stickData;
|
|
20
|
+
this.targetHeight = this.data.targetHeight;
|
|
21
|
+
this.html = document.body;
|
|
22
|
+
this.res = document.createElement("div"); // stack
|
|
23
|
+
this.res.setAttribute("id", this.data.id);
|
|
24
|
+
this.res.style.border = "1px solid green";
|
|
25
|
+
this.res.style.width = "100%";
|
|
26
|
+
this.res.style.display = "grid";
|
|
27
|
+
|
|
28
|
+
//
|
|
29
|
+
this.res.style.position = "sticky";// removed
|
|
30
|
+
this.res.style.top = 0;
|
|
31
|
+
this.res.style.alignSelf = "flex-start";
|
|
32
|
+
|
|
33
|
+
this.res.style.justifyContent = "center";
|
|
34
|
+
this.res.style.alignItems = "center";
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// Added
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if (!this.data.added){ // Nice effect with false
|
|
41
|
+
this.res.style.marginTop = this.data.noAddedDistance; //"800px";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
this.frameCount = 100; // 100
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
this.lastScrollTop = window.scrollY;
|
|
52
|
+
// modrý a bez kroužku
|
|
53
|
+
this.setupTopElement();
|
|
54
|
+
this.scrollFunction();
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
window.addEventListener('scroll', () => {
|
|
59
|
+
this.scrollFunction();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
this.preloadImages();
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
marginTop(data){
|
|
68
|
+
// this.data.noAddedDistance = data;
|
|
69
|
+
this.res.style.marginTop = data;
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
toCode(){
|
|
74
|
+
return [""];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
scrollFunction = () => {
|
|
78
|
+
// alert(this.flagValue);
|
|
79
|
+
|
|
80
|
+
// console.log(this.flagValue);
|
|
81
|
+
|
|
82
|
+
if (this.flagValue === undefined){
|
|
83
|
+
this.flagValue = 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var scrollTop = this.html.scrollTop - /*1700*/ this.flagValue;
|
|
87
|
+
var maxScrollTop = this.html.scrollHeight - window.innerHeight;
|
|
88
|
+
|
|
89
|
+
const scrollFraction = scrollTop / maxScrollTop * 16 /** 16*/ ; // TIMES 5 Speeds up the animation
|
|
90
|
+
var frameIndex = Math.min(
|
|
91
|
+
this.frameCount - 1,
|
|
92
|
+
Math.ceil(scrollFraction * this.frameCount)
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
/* if (frameIndex === 99) {
|
|
96
|
+
frameIndex -= 99;
|
|
97
|
+
}*/
|
|
98
|
+
|
|
99
|
+
if (isNaN(frameIndex)) {
|
|
100
|
+
frameIndex = 1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (frameIndex < 0){
|
|
104
|
+
frameIndex = 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// console.log(frameIndex);
|
|
108
|
+
|
|
109
|
+
if (this.data.limit){
|
|
110
|
+
|
|
111
|
+
if (frameIndex < this.data.limit){
|
|
112
|
+
// console.log(frameIndex)
|
|
113
|
+
// console.log("MY Frame index is" + frameIndex);
|
|
114
|
+
requestAnimationFrame(() => this.updateImage(frameIndex + 1));
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
requestAnimationFrame(() => this.updateImage(frameIndex + 1));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
let query = window.matchMedia("(max-device-width: 415px)");
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
// Apple website does not transition...
|
|
125
|
+
/* if (query.matches === false){
|
|
126
|
+
if (window.scrollY > 2300){
|
|
127
|
+
this.res.style.position = "relative";
|
|
128
|
+
this.res.style.marginTop = "1300px";
|
|
129
|
+
} else {
|
|
130
|
+
this.res.style.marginTop = "800px";
|
|
131
|
+
this.res.style.position = "sticky";
|
|
132
|
+
}
|
|
133
|
+
}*/
|
|
134
|
+
|
|
135
|
+
// scroll less than 2300 and fix next
|
|
136
|
+
|
|
137
|
+
/* if (window.scrollY > 2300){
|
|
138
|
+
this.res.style.position = "relative";
|
|
139
|
+
this.res.style.marginTop = "1400px";
|
|
140
|
+
} else {
|
|
141
|
+
this.res.style.marginTop = "800px";
|
|
142
|
+
this.res.style.position = "sticky";
|
|
143
|
+
}*/
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
currentFrame = index => {
|
|
148
|
+
// https://stackoverflow.com/questions/5417979/batch-rename-sequential-files-by-padding-with-zeroes Thanks !
|
|
149
|
+
// for f in *.jpg;do n=${f#*_};n=${n%.*};mv $f $(printf "%04d".jpg $n);done
|
|
150
|
+
let res = `${this.data.path}${index.toString().padStart(4, '0')}.${this.data.extension}`;
|
|
151
|
+
return res;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
preloadImages = () => {
|
|
155
|
+
for (let i = 1; i < this.frameCount; i++) {
|
|
156
|
+
const img = new Image();
|
|
157
|
+
this.img.src = this.currentFrame(i);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
updateImage = index => {
|
|
162
|
+
// console.log(index);
|
|
163
|
+
|
|
164
|
+
this.img.src = this.currentFrame(index);
|
|
165
|
+
|
|
166
|
+
/* if (window.scrollY > 20 && index > 98){
|
|
167
|
+
this.res.style.position = "relative";
|
|
168
|
+
this.res.style.marginTop = "420px";
|
|
169
|
+
} */
|
|
170
|
+
|
|
171
|
+
/* if (window.scrollY < 620 && this.isUp){ // 163408 okay, get exact value
|
|
172
|
+
this.res.style.position = "fixed";
|
|
173
|
+
this.res.style.marginTop = "0px";
|
|
174
|
+
}*/
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
// WILL NOT WORK
|
|
178
|
+
/* if (window.scrollY > 1370 && !this.isUp){
|
|
179
|
+
this.res.style.position = "fixed";
|
|
180
|
+
this.res.style.marginTop = "0px";
|
|
181
|
+
} // 17:12:25 08/10/23 afetr win UH nice!
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
if (window.scrollY <= 1370 && this.isUp){
|
|
186
|
+
this.res.style.position = "relative";
|
|
187
|
+
this.res.style.marginTop = "800px";
|
|
188
|
+
} // 21:55:43 Nice !!!
|
|
189
|
+
*/
|
|
190
|
+
// 22:20:50 developer tools change the necessary window.scrollY value
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
drawImageProp(ctx, img, x, y, w, h, offsetX, offsetY) {
|
|
198
|
+
|
|
199
|
+
if (arguments.length === 2) {
|
|
200
|
+
x = y = 0;
|
|
201
|
+
w = ctx.canvas.width;
|
|
202
|
+
h = ctx.canvas.height;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// default offset is center
|
|
206
|
+
offsetX = typeof offsetX === "number" ? offsetX : 0.5;
|
|
207
|
+
offsetY = typeof offsetY === "number" ? offsetY : 0.5;
|
|
208
|
+
|
|
209
|
+
// keep bounds [0.0, 1.0]
|
|
210
|
+
if (offsetX < 0) offsetX = 0;
|
|
211
|
+
if (offsetY < 0) offsetY = 0;
|
|
212
|
+
if (offsetX > 1) offsetX = 1;
|
|
213
|
+
if (offsetY > 1) offsetY = 1;
|
|
214
|
+
|
|
215
|
+
var iw = img.width,
|
|
216
|
+
ih = img.height,
|
|
217
|
+
r = Math.min(w / iw, h / ih),
|
|
218
|
+
nw = iw * r, // new prop. width
|
|
219
|
+
nh = ih * r, // new prop. height
|
|
220
|
+
cx, cy, cw, ch, ar = 1;
|
|
221
|
+
|
|
222
|
+
// decide which gap to fill
|
|
223
|
+
if (nw < w) ar = w / nw;
|
|
224
|
+
if (Math.abs(ar - 1) < 1e-14 && nh < h) ar = h / nh; // updated
|
|
225
|
+
nw *= ar;
|
|
226
|
+
nh *= ar;
|
|
227
|
+
|
|
228
|
+
// calc source rectangle
|
|
229
|
+
cw = iw / (nw / w);
|
|
230
|
+
ch = ih / (nh / h);
|
|
231
|
+
|
|
232
|
+
cx = (iw - cw) * offsetX;
|
|
233
|
+
cy = (ih - ch) * offsetY;
|
|
234
|
+
|
|
235
|
+
// make sure source rectangle is valid
|
|
236
|
+
if (cx < 0) cx = 0;
|
|
237
|
+
if (cy < 0) cy = 0;
|
|
238
|
+
if (cw > iw) cw = iw;
|
|
239
|
+
if (ch > ih) ch = ih;
|
|
240
|
+
|
|
241
|
+
console.log("WEIRD")
|
|
242
|
+
console.log(img);
|
|
243
|
+
console.log(cy);
|
|
244
|
+
console.log(cw);
|
|
245
|
+
// fill image in dest. rectangle
|
|
246
|
+
ctx.drawImage(img, cx, cy, cw, ch, x, y, w, h);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
maska(data){
|
|
251
|
+
window.addEventListener("scroll", () => {
|
|
252
|
+
this.innerMask(data);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
return this;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
innerMask(data) {
|
|
259
|
+
if (data) {
|
|
260
|
+
let smart = smartRange(window.scrollY, { min: data.start, max: data.end }, { min: 0, max: 7 }) // The other way
|
|
261
|
+
let radius = smartRange(window.scrollY, { min: data.start, max: data.end }, { min: 37, max: 37 }) // both are 20 to stay round
|
|
262
|
+
this.res.style.clipPath = `inset(${smart}% ${smart}% round 0 0 ${radius}px ${radius}px)`;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
setupTopElement() {
|
|
267
|
+
// If we scroll further after seeing topElement
|
|
268
|
+
console.warn("TOP INIT");
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
// 1 - Set up the stack
|
|
273
|
+
// 2 - Set up bottom elements
|
|
274
|
+
let fixTop = document.createElement("canvas");
|
|
275
|
+
|
|
276
|
+
fixTop.style.gridArea = "1/1";
|
|
277
|
+
fixTop.zIndex = 1;
|
|
278
|
+
fixTop.style.display = "grid";
|
|
279
|
+
fixTop.style.gridTemplate = "1fr/1fr";
|
|
280
|
+
fixTop.style.justifyContent = "center";
|
|
281
|
+
fixTop.style.alignItems = "center";
|
|
282
|
+
fixTop.style.marginLeft = "auto";
|
|
283
|
+
fixTop.style.marginRight = "auto";
|
|
284
|
+
// fixTop.style.width = "100%";
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
this.context = fixTop.getContext("2d");
|
|
288
|
+
|
|
289
|
+
// 1158; WAS GOOD
|
|
290
|
+
this.context.canvas.width = window.innerWidth; //document.body.clientWidth; // Make this responsive
|
|
291
|
+
this.context.canvas.height = window.innerHeight * 1.2; //window.innerWidth / 1.77778;
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
this.img = new Image();
|
|
297
|
+
|
|
298
|
+
this.img.onload = () => {
|
|
299
|
+
if (this.data.halfHeight){
|
|
300
|
+
this.drawImageProp(this.context, this.img, 0, 0, window.innerWidth, window.innerHeight / 2);
|
|
301
|
+
} else {
|
|
302
|
+
this.drawImageProp(this.context, this.img, 0, 0, window.innerWidth, window.innerHeight * 1.2);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
// 11:41:33 Nice!
|
|
308
|
+
// 17/10/2023
|
|
309
|
+
// M2 iPad Air and iPad (11th gen) are coming today!
|
|
310
|
+
window.addEventListener("resize", () => {
|
|
311
|
+
this.context.canvas.width = window.innerWidth; //document.body.clientWidth; // Make this responsive
|
|
312
|
+
this.context.canvas.height = window.innerHeight * 1.2; //window.innerWidth / 1.77778;
|
|
313
|
+
this.drawImageProp(this.context, this.img, 0, 0, window.innerWidth, window.innerHeight * 1.2);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// https://twitter.com/L0vetodream/status/1240753794037600256
|
|
317
|
+
|
|
318
|
+
// git reflog 180427 git reset HEAD@{index}
|
|
319
|
+
this.res.appendChild(fixTop);
|
|
320
|
+
if (this.data.text) {
|
|
321
|
+
let wrap = document.createElement("div");
|
|
322
|
+
wrap.style.gridArea = "1/1";
|
|
323
|
+
|
|
324
|
+
let el = this.data.text.render();
|
|
325
|
+
this.h2a = el;
|
|
326
|
+
wrap.appendChild(el);
|
|
327
|
+
wrap.setAttribute("id", "rem");
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
if (this.data.hasRect) {
|
|
334
|
+
let e = document.createElement("div");
|
|
335
|
+
e.style.width = "30px";
|
|
336
|
+
e.style.height = "30px";
|
|
337
|
+
e.style.backgroundColor = "orange";
|
|
338
|
+
} else {
|
|
339
|
+
for (var i = 0; i < this.res.children.length; i++) {
|
|
340
|
+
if (this.res.children[i].id === "rem") {
|
|
341
|
+
this.res.removeChild(this.res.children[i]);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
this.res.appendChild(wrap);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
this.lastScrollTop = 0;
|
|
351
|
+
this.count = 1;
|
|
352
|
+
this.isUp = false;
|
|
353
|
+
this.done = false;
|
|
354
|
+
this.fireOnce = true;
|
|
355
|
+
this.dec = 1.0;
|
|
356
|
+
this.tdec = 1.0;
|
|
357
|
+
this.atdec = 0.0;
|
|
358
|
+
this.textOpacity = 1.0;
|
|
359
|
+
|
|
360
|
+
let hTwo = this.res.children[this.res.children.length - 1].children[0];
|
|
361
|
+
// hTwo.opacity = 0;
|
|
362
|
+
hTwo.style.opacity = 0;
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
if (this.data.text){
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
window.addEventListener("scroll", () => {
|
|
371
|
+
this.h2a.style.backgroundColor = "rgba(0, 0, 0, 0.8)"; //"black";
|
|
372
|
+
this.h2a.style.opacity = 1;
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
/* let offset = smartRange(window.scrollY, {
|
|
376
|
+
// min: this.data.lazyText.start,
|
|
377
|
+
// max: this.data.lazyText.end
|
|
378
|
+
min: 6180,
|
|
379
|
+
max: 8000
|
|
380
|
+
}, {
|
|
381
|
+
min: 0,
|
|
382
|
+
max: 200
|
|
383
|
+
}); // 175
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
let opacity = smartRange(window.scrollY, {
|
|
387
|
+
// min: this.data.lazyText.start,
|
|
388
|
+
// max: this.data.lazyText.end
|
|
389
|
+
min: 6180, // variable args
|
|
390
|
+
max: 8000
|
|
391
|
+
}, {
|
|
392
|
+
min: 0,
|
|
393
|
+
max: 1
|
|
394
|
+
}); // 175
|
|
395
|
+
*/
|
|
396
|
+
// div below #rem has opacity 0
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
/* for (var i = 0; i < this.h2a.children[0].children.length; i++){
|
|
400
|
+
console.log("P")
|
|
401
|
+
this.h2a.children[0].children[i].style.transform = `matrix(1, 0, 0, 1, 0, -${offset})`;
|
|
402
|
+
this.h2a.children[0].children[i].style.opacity = `${opacity - i * 0.2}`;
|
|
403
|
+
}*/
|
|
404
|
+
|
|
405
|
+
// this.h2a.style.transform = "matrix("
|
|
406
|
+
// transform: matrix(1, 0, 0, 1, 0, 15.2135);
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
/* let offset = smartRange(window.scrollY, {
|
|
410
|
+
min: 3750,
|
|
411
|
+
max: 4000
|
|
412
|
+
}, {
|
|
413
|
+
min: 0,
|
|
414
|
+
max: 200
|
|
415
|
+
}); // 175
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
let opacity = smartRange(window.scrollY, {
|
|
419
|
+
min: 3750,
|
|
420
|
+
max: 4200
|
|
421
|
+
}, {
|
|
422
|
+
min: 0,
|
|
423
|
+
max: 1
|
|
424
|
+
}); // 175
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
for (var i = 0; i < this.h2a.children[0].children.length; i++){
|
|
430
|
+
this.h2a.children[0].children[i].style.transform = `matrix(1, 0, 0, 1, 0, -${offset})`;
|
|
431
|
+
this.h2a.children[0].children[i].style.opacity = `${opacity - i * 0.2}`;
|
|
432
|
+
}*/
|
|
433
|
+
// this.h2a.children[0].children[1].style.backgroundColor = "orange";
|
|
434
|
+
|
|
435
|
+
// this.h2a.children[0].style.transform = `matrix(1, 0, 0, 1, 0, -${offset})`;
|
|
436
|
+
|
|
437
|
+
// height here
|
|
438
|
+
// 1800-2200
|
|
439
|
+
|
|
440
|
+
/* let res = smartRange(window.scrollY, {
|
|
441
|
+
// min: 1800,
|
|
442
|
+
// max: 2200
|
|
443
|
+
// min: 30,
|
|
444
|
+
// max: 800
|
|
445
|
+
|
|
446
|
+
min: this.data.opacityRange.start,
|
|
447
|
+
max: this.data.opacityRange.end
|
|
448
|
+
}, {
|
|
449
|
+
min: 0,
|
|
450
|
+
max: 1
|
|
451
|
+
}); // 175*/
|
|
452
|
+
|
|
453
|
+
// console.log(res);
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
// this.h2a.style.opacity = res;
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
window.addEventListener("scroll", (e) => {
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
// newly added
|
|
473
|
+
if (this.data.stickyData){
|
|
474
|
+
if (this.data.stickyData.top){
|
|
475
|
+
const top = this.data.stickyData.top; //800;
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
// UNCOMMENT HERE
|
|
479
|
+
|
|
480
|
+
// alert(wrapDiv);
|
|
481
|
+
if (this.data.uncomment) {
|
|
482
|
+
if (window.scrollY > top) { // MAKE THIS ADJUSTABLE
|
|
483
|
+
wrapDiv.style.background = "pink";
|
|
484
|
+
wrapDiv.style.position = "relative";
|
|
485
|
+
wrapDiv.style.top = top; // FIX HERE
|
|
486
|
+
} else {
|
|
487
|
+
wrapDiv.style.background = "orange";
|
|
488
|
+
wrapDiv.style.top = 0;
|
|
489
|
+
wrapDiv.style.position = "fixed";
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
// console.log(window.scrollY);
|
|
498
|
+
|
|
499
|
+
let st = window.scrollY || document.documentElement.scrollTop;
|
|
500
|
+
if (st > this.lastScrollTop) {
|
|
501
|
+
this.isUp = false;
|
|
502
|
+
} else {
|
|
503
|
+
this.isUp = true;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
this.lastScrollTop = st <= 0 ? 0 : st; // For Mobile or negative scrolling
|
|
507
|
+
|
|
508
|
+
if (this.isUp) {
|
|
509
|
+
if (this.textOpacity < 0.98) {
|
|
510
|
+
this.textOpacity += 0.01;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (this.isUp === false) {
|
|
515
|
+
if (this.textOpacity > 0.02) {
|
|
516
|
+
this.textOpacity -= 0.01;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if (this.data.mask){
|
|
521
|
+
|
|
522
|
+
let rem = this.res; //document.querySelector("#beauty");
|
|
523
|
+
|
|
524
|
+
let smart = smartRange(window.scrollY, {/*min: 2189, max: 2900*/ min: this.data.maskData.start, max: this.data.maskData.end}, {min: 0, max: 7} )
|
|
525
|
+
rem.style.clipPath = `inset(${smart}% ${smart}% round 20px)`;
|
|
526
|
+
// console.log(`SMART: ${smart}`);
|
|
527
|
+
// console.log(this.textOpacity);
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
if (!this.hasH2){
|
|
531
|
+
let grayBack = document.createElement("div");
|
|
532
|
+
grayBack.style.background = "#ecf0f1";
|
|
533
|
+
grayBack.style.width = "86%";
|
|
534
|
+
grayBack.style.marginLeft = "7%";
|
|
535
|
+
grayBack.style.borderRadius = "1rem";
|
|
536
|
+
|
|
537
|
+
this.hasH2 = true;
|
|
538
|
+
grayBack.appendChild(this.data.newSection.render());
|
|
539
|
+
rem.parentElement.appendChild(grayBack);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// 22:09:11 Code design object
|
|
544
|
+
let elHeight = this.data.targetHeight;
|
|
545
|
+
let begin = elHeight - 250;
|
|
546
|
+
let end = elHeight + 250;
|
|
547
|
+
|
|
548
|
+
/* let res = sm(st + begin, {
|
|
549
|
+
min: begin,
|
|
550
|
+
max: end
|
|
551
|
+
}, {
|
|
552
|
+
min: 0,
|
|
553
|
+
max: 2
|
|
554
|
+
}); // 175
|
|
555
|
+
|
|
556
|
+
if (res < -0.3) {
|
|
557
|
+
res = Math.abs(res);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
if (this.data.animation != "float") {
|
|
561
|
+
hTwo.style.opacity = `${res}`;
|
|
562
|
+
}*/
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
setLazyText(obj){
|
|
572
|
+
this.lazyText= obj;
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
window.addEventListener("scroll", () => {
|
|
576
|
+
let offset = smartRange(window.scrollY, {
|
|
577
|
+
min: this.lazyText.start,
|
|
578
|
+
max: this.lazyText.end
|
|
579
|
+
// min: 6180,
|
|
580
|
+
// max: 8000
|
|
581
|
+
}, {
|
|
582
|
+
min: 0,
|
|
583
|
+
max: 200
|
|
584
|
+
}); // 175
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
let opacity = smartRange(window.scrollY, {
|
|
588
|
+
min: this.lazyText.start,
|
|
589
|
+
max: this.lazyText.end
|
|
590
|
+
// min: 6180, // variable args
|
|
591
|
+
// max: 8000
|
|
592
|
+
}, {
|
|
593
|
+
min: 0,
|
|
594
|
+
max: 1
|
|
595
|
+
}); // 175
|
|
596
|
+
|
|
597
|
+
// div below #rem has opacity 0
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
for (var i = 0; i < this.h2a.children[0].children.length; i++){
|
|
601
|
+
console.log("P")
|
|
602
|
+
this.h2a.children[0].children[i].style.transform = `matrix(1, 0, 0, 1, 0, -${offset})`;
|
|
603
|
+
this.h2a.children[0].children[i].style.opacity = `${opacity - i * 0.2}`;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
return this;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
setProps(obj){
|
|
613
|
+
|
|
614
|
+
if (obj.targetHeight){
|
|
615
|
+
this.data.targetHeight = obj.targetHeight;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
if (obj.flagValue){
|
|
620
|
+
// alert(obj.flagValue);
|
|
621
|
+
this.flagValue = obj.flagValue;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
return this;
|
|
625
|
+
/* targetHeight: 600,
|
|
626
|
+
flagValue: 3700,*/
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
fixedToRelative(value){
|
|
631
|
+
this.data.uncomment = value;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
toSticky(){
|
|
635
|
+
this.res.style.position = "sticky";
|
|
636
|
+
this.res.style.top = "0";
|
|
637
|
+
return this;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
setOpacityRange(range){
|
|
641
|
+
this.data.opacityRange = range.opacityRange;
|
|
642
|
+
this.data.scaleRange = range.scaleRange;
|
|
643
|
+
// 1800 and 2200 scale
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
window.addEventListener("scroll", () => {
|
|
647
|
+
let res = smartRange(window.scrollY, {
|
|
648
|
+
// min: 1800,
|
|
649
|
+
// max: 2200
|
|
650
|
+
// min: 30,
|
|
651
|
+
// max: 800
|
|
652
|
+
|
|
653
|
+
min: this.data.opacityRange.start,
|
|
654
|
+
max: this.data.opacityRange.end
|
|
655
|
+
}, {
|
|
656
|
+
min: 0,
|
|
657
|
+
max: 1
|
|
658
|
+
}); // 175
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
this.h2a.style.opacity = res;
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
let scale = smartRange(window.scrollY, {
|
|
665
|
+
min: this.data.scaleRange.start,
|
|
666
|
+
max: this.data.scaleRange.end,
|
|
667
|
+
}, {
|
|
668
|
+
min: 3,
|
|
669
|
+
max: 1
|
|
670
|
+
}); // 175
|
|
671
|
+
|
|
672
|
+
/* let scaleChip = smartRange(window.scrollY, {
|
|
673
|
+
min: 1800,
|
|
674
|
+
max: 2200
|
|
675
|
+
}, {
|
|
676
|
+
min: 3,
|
|
677
|
+
max: 0.6
|
|
678
|
+
}); // 175
|
|
679
|
+
*/
|
|
680
|
+
// Bad on mobile
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
// 00:29:51
|
|
684
|
+
if (!window.matchMedia("(max-device-width: 415px)").matches){
|
|
685
|
+
this.h2a.children[0].style.transform = `scale(${scale})`;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
return this;
|
|
691
|
+
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
/*
|
|
697
|
+
stick(value){
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
if (topOffset != undefined){
|
|
701
|
+
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (value){
|
|
705
|
+
this.makeSticky();
|
|
706
|
+
} else {
|
|
707
|
+
this.noSticky();
|
|
708
|
+
}
|
|
709
|
+
return this;
|
|
710
|
+
}*/
|
|
711
|
+
|
|
712
|
+
stick(obj){
|
|
713
|
+
if (!obj){
|
|
714
|
+
this.makeSticky();
|
|
715
|
+
return this;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
if (obj.offset){
|
|
720
|
+
if (this.data.stickyData != undefined){
|
|
721
|
+
// alert(topOffset);
|
|
722
|
+
this.data.stickyData.top = obj.offset;
|
|
723
|
+
} else {
|
|
724
|
+
this.data.stickyData = {top: obj.offset};
|
|
725
|
+
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
if (obj.value){
|
|
730
|
+
this.makeSticky();
|
|
731
|
+
} else {
|
|
732
|
+
this.noSticky();
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
return this;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
to100vh(){
|
|
739
|
+
this.res.style.height = "100vh";
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
makeSticky(){
|
|
744
|
+
this.res.style.position = "sticky";
|
|
745
|
+
this.res.style.top = 0;
|
|
746
|
+
|
|
747
|
+
// 22:23:18 Yes!!!
|
|
748
|
+
// 22:23:39 mobile
|
|
749
|
+
//this.wrdiv.style.marginTop = "800px";
|
|
750
|
+
return this;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
noSticky(){
|
|
755
|
+
// this.wrdiv.style.display = "none";
|
|
756
|
+
// this.wrdiv.style.filter = "grayscale(1)";
|
|
757
|
+
this.res.style.position = "";
|
|
758
|
+
return this;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
toOpacity(opacity){
|
|
763
|
+
this.res.style.opacity = `${opacity}`;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
render(id) {
|
|
768
|
+
// this.res.style.position = "fixed";
|
|
769
|
+
if (id) {
|
|
770
|
+
document.querySelector(id).appendChild(this.res);
|
|
771
|
+
} else {
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
// Move this out to wrapper Layout element
|
|
775
|
+
/* let el = document.createElement("div");
|
|
776
|
+
el.style.height = "2300px";
|
|
777
|
+
this.res.style.height = "100vh";
|
|
778
|
+
el.appendChild(this.res);*/
|
|
779
|
+
|
|
780
|
+
return this.res;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
export {KeyframeAnim};
|
|
788
|
+
|
|
789
|
+
// http://localhost:64595/designertest/5-CleanScrollAnimation/cleaner-way
|