-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
1357 lines (1281 loc) · 207 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
all();
function all() {
animateCss();
animateJs();
moJs();
animateGsap();
}
function animateGsap() {
gsap.registerPlugin(TextPlugin);
let elmGsap = document.querySelectorAll(".anmiateGsap");
let words = gsap.utils.toArray(".anmiateGsap-1 .anmiateGsap-2"),
tl = gsap.timeline({ delay: 0.5 }),
timePerCharacter = 0.2;
words.forEach((el) => {
tl.from(el, {
text: "",
duration: el.innerHTML.length * timePerCharacter,
ease: "none",
});
});
// * ======> GSAP <======\\
let btnGsap_1 = document.querySelector("#btnGsap-1");
let btnGsap_2 = document.querySelector("#btnGsap-2");
btnGsap_1.addEventListener("click", () => {
gsap.to(".box-left", {
x: "38vw",
rotation: 360,
duration: 5,
});
gsap.to(".box-right", {
x: "-38vw",
rotation: -360,
duration: 5,
});
});
btnGsap_2.addEventListener("click", () => {
gsap.to(".box-left", {
x: "0vw",
rotation: -360,
duration: 5,
});
gsap.to(".box-right", {
x: "0vw",
rotation: 360,
duration: 5,
});
});
gsap.to(".svgBox", {
duration: 2,
x: 300, // use transform shorthand (this is now using SVG units not px, the SVG viewBox is 100 units wide)
xPercent: -80,
// or target SVG attributes
attr: {
fill: "#8d3dae",
rx: 50,
},
});
//create an object
let test = { myNum: 10, myColor: "red" };
gsap.to("test", test, {
myNum: 200,
myColor: "blue",
onUpdate: () => console.log(test.myNum, test.myColor),
});
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#1A1A1A";
let position = { x: 0, y: 0 };
function draw() {
// erase the canvas
ctx.clearRect(0, 0, 320, 320);
// redraw the square at it's new position
ctx.fillRect(position.x, position.y, 100, 50);
}
//animate x and y of point
gsap.to(position, {
x: 120,
y: 120,
duration: 4,
// unlike DOM elements, canvas needs to be redrawn and cleared on every tick
onUpdate: draw,
});
gsap.to(".test", {
rotation: 360,
x: "-100vw",
xPercent: 700,
// special properties
duration: 2, // how long the animation lasts
repeat: 100, // the number of repeats - this will play 3 times
yoyo: true, // this will alternate back and forth on each repeat. Like a yoyo
});
gsap.to(".red-left", {
rotation: 360,
duration: 1,
repeat: 1,
repeatDelay: 1,
});
gsap.to(".violet-right", {
rotation: 360,
duration: 1,
delay: 1, // delay the start of this animation
});
gsap.to(".red-linear", {
rotation: 360,
duration: 2,
repeat: -1,
repeatDelay: 2,
ease: "none",
});
gsap.to(".violet-bounce", {
rotation: 360,
duration: 2,
repeat: -1,
repeatDelay: 2,
ease: "bounce.out",
});
}
gsap.to(".box", {
duration: 1,
rotation: 360,
opacity: 1,
delay: 0.5,
stagger: 0.2,
ease: "sine.out",
force3D: true,
});
document.querySelectorAll(".box").forEach(function (box) {
box.addEventListener("click", function () {
gsap.to(".box", {
duration: 0.5,
opacity: 0,
y: -100,
stagger: 0.1,
ease: "back.in",
});
});
});
let tl = gsap.timeline({ repeat: 2, repeatDelay: 1 });
tl.to(".racket", {
duration: 1,
rotation: 90,
});
tl.to(".racket", {
duration: 1,
x: "80vw",
ease: "expo",
});
tl.to(".racket", {
duration: 1,
ease: "expo",
});
//register the plugin (just once)
gsap.registerPlugin(MotionPathPlugin);
gsap.set(".astronaut", { scale: 0.5, autoAlpha: 1 });
gsap.to(".astronaut", {
duration: 5,
ease: "power1.inOut",
immediateRender: true,
motionPath: {
path: "#path",
align: "#path",
alignOrigin: [0.5, 0.5],
autoRotate: 90,
},
});
let svgminiBus = document.querySelector("#container-txt-gsap");
svgminiBus.insertAdjacentHTML("beforeend", svg_miniBus());
window.addEventListener("scroll", gasp_scroll);
function gasp_scroll(e) {
console.log(window.scrollY);
if (window.scrollY > 3662) {
gsap.to("#miniBus", {
x: -280,
duration: 3,
yoyo: true,
repeat: 1,
});
gsap.to("#text-gsap", {
x: -280,
duration: 3,
});
} else {
gsap.to("#miniBus", {
x: 0,
duration: 3,
repeat: 1,
});
gsap.to("#text-gsap", {
x: -0,
duration: 3,
});
}
}
//? ==================================\\
//* ==========gsap-gallery=============\\
//? ==================================\\
let slider = document.querySelectorAll(".img");
let sliderArr = Array.from(slider);
let onShow = false;
let createElmcode = document.createElement("code");
const colors = [
"#ffffff", // سیاه
"#000000", // سفید
"#ff0000", // قرمز
"#00ff00", // سبز
"#0000ff", // آبی
"#ffff00", // زرد
"#ff00ff", // بنفش
"#00ffff", // فیروزهای
"#808080", // خاکستری
"#c0c0c0", // نقرهای
"#f0f0f0", // سفید دودی
"#d3d3d3", // خاکستری روشن
"#a9a9a9", // خاکستری تیره
"#ff7f00", // نارنجی
"#00ff7f", // سبز روشن
"#7f00ff", // بنفش روشن
"#ff7fff", // صورتی
"#7fff00", // زرد لیمویی
"#7fffff", // آبی آسمانی
"#f000ff", // سرخابی
"#00f0ff", // آبی لاجوردی
"#ffff7f", // زرد کمرنگ
"#d2b48c", // قهوهای
"#ffa500", // نارنجی تیره
"#008000", // سبز تیره
"#008080", // آبی تیره
"#800000", // قهوهای سوخته
"#800080", // بنفش تیره
"#ffa07a", // رنگ پوست
"#ff4500", // نارنجی سوخته
"#00ff80", // سبزآبی
"#7f0080", // بنفش مایل به قرمز
"#7f8000", // قهوهای مایل به زرد
"#7f8080", // خاکستری مایل به قهوهای
];
let xPos = 0;
gsap
.timeline()
.set(".ringGsap", { rotationY: 180, cursor: "grab" }) //set initial rotationY so the parallax jump happens off screen
.set(".img", {
// apply transform rotations to each image
rotateY:(i)=>i*-36,
transformOrigin: "50% 50% 1050",
z: -1050,
backgroundColor: (i) => colors[i],
backgroundPosition: (i) => getBgPos(i),
backfaceVisibility: "hidden",
})
.from(".img", {
duration: 1.5,
y: 200,
opacity: 0,
stagger: 0.1,
ease: "expo",
})
.add((e,i) => {
$(".img").on("mouseenter", (e) => {
let current = e.currentTarget;
let target = e.target;
gsap.to(".img > button", { opacity: 1 });
gsap.to(".img", {
opacity: (i, t) => (t == current ? 1 : 0.5),
ease: "power1",scale: 0.8
});
gsap.to(e.target, { scale: 1.3, });
gsap.to(".basket-left", { x:"200" ,rotation:-360 ,duration:1.5 });
gsap.to(".basket-right", { x:"-200" ,rotation: 360 ,duration:1.5 });
});
$(".img").on("mouseleave", (e) => {
gsap.to(".img", { opacity: 1, ease: "power1.inOut" });
gsap.to(e.target, { scale: 0.8 });
gsap.to(".basket-left", { x:"-0" ,rotation:360 ,duration:1.5 });
gsap.to(".basket-right", { x:"0" ,rotation:-360 ,duration:1.5 });
gsap.to(".img > button", { opacity: 0 });
createElmcode.remove();
onShow = false;
});
$(".img").on("click", (e) => {
let parent = e.target.parentNode;
// parent.insertAdjacentHTML('beforeend',"<pre class='w-2/4 h-2/4 bg-amber-400 m-0 p-0 '><code class='language-js'></code></pre>");
parent.appendChild(createElmcode);
if (!onShow) {
createElmcode.classList.add("flex", "justify-center", "w-full", "h-full");
createElmcode.innerHTML = `<pre class='w-5/6 h-5/6 bg-amber-400 m-0 p-0 '><code class='language-js'>let const =document.querySelector('.img')
console.log(const);
Source Code
</code></pre>`;
onShow = true;
} else{ createElmcode.remove(), (onShow = false);
}
console.log(e.target);
});
}, "-=0.5");
//gsap.globalTimeline.timeScale(0.25)
// for (let i = 0; i < sliderArr.length; i++) {
// const elementSlide = sliderArr[i];
// elementSlide.insertAdjacentHTML(
// "beforeend",
// `<button class="show p-3 bg-red-400">show</button>`,
// );
// elmShow[i].addEventListener("click", (e) => {
// });
// elmShow.addEventListener('click',(e)=>{
// console.log(e.target.parentNode);
// })
// }
$(window).on("mousedown touchstart", dragStart);
$(window).on("mouseup touchend", dragEnd);
function dragStart(e) {
if (e.touches) e.clientX = e.touches[0].clientX;
xPos = Math.round(e.clientX);
gsap.set(".ringGsap", { cursor: "grabbing" });
$(window).on("mousemove touchmove", drag);
}
/**
* Function for handling drag events.
*
* @param {object} e - The event object containing drag information
* @return {void} This function does not return anything
*/
function drag(e) {
if (e.touches) e.clientX = e.touches[0].clientX;
gsap.to(".ringGsap", {
rotationY: "-=" + ((Math.round(e.clientX) - xPos) % 360),
onUpdate: () => {
gsap.set(".img", { backgroundPosition: (i) => getBgPos(i) });
},
});
// gsap.to('#text-gsap-2', { rotation: '-=' +( (Math.round(e.clientX)-xPos)%360 ),});
xPos = Math.round(e.clientX);
}
/**
* Function to handle the end of a drag event.
*
* @param {Event} e - the drag event object
* @return {void}
*/
function dragEnd(e) {
$(window).off("mousemove touchmove", drag);
gsap.set(".ringGsap", { cursor: "grab" });
}
/**
* Returns the background-position string to create parallax movement in each image.
*
* @param {number} i - the parameter for parallax movement calculation
* @return {string} the background-position string
*/
function getBgPos(i) {
//returns the background-position string to create parallax movement in each image
return (
100 -
(gsap.utils.wrap(
0,
360,
gsap.getProperty(".ringGsap", "rotationY") - 180 - i * 36,
) /
360) *
500 +
"px 0px"
);
}
// const cube = new Mesh(geometry, material)
// scene.add(cube)
// gsap.to(cube.rotation, {
// x: Math.PI * 2,
// y: Math.PI * 2,
// duration: 10,
// repeat: -1,
// ease: "none",
// onUpdate: () => {
// renderer.render(scene, camera)
// },
// })
// ////////////////////////////////////////
//? =========> Code AnimeJs ALL <========\\
// ////////////////////////////////////////
let codeAnmieJs_All = [
`
<div id="innerSourceCodeAnimeJs" class="relative flex p-2 w-full h-42 z-10 animate__animated animate__zoomInDown bg-slate-200/30 border-8 ring ring-rose-500 border-double">
<div class="w-2/4 p-2 bg-rose-600/20 text-white h-auto">
<h2 class="text-white"><<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">function-based-params-demo</span>">
<h2 class="text-white"><<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">el</span>"> <<span class="text-yellow-600">/div</span>></h2>
<h2 class="text-white"><<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">el</span>">
<<span class="text-yellow-600">/div</span>></h2>
<<span class="text-yellow-600">/div</span>></h2>
</div>
<div class="w-2/4 bg-rose-600/20 h-auto">
<pre><span class="text-blue-800">anime</span>({
<span class="text-green-600"> targets:</span> <span class="text-yellow-400">'.function-based-params-demo .el'</span>,
<span class="text-green-600">translateX:</span><span class="text-yellow-400"> 270,</span>
<span class="text-green-600">direction:</span> <span class="text-yellow-400">'alternate',</span>
<span class="text-green-600">loop:</span><span class="text-yellow-400"> true,</span>
<span class="text-blue-600">delay:</span> <span class="text-yellow-400">function(el, i, l) {</span>
<span class="text-green-600"></span><span class="text-purple-700"> return</span> i * 100;
<span class="text-yellow-400">},</span>
<span class="text-blue-600">endDelay:</span><span class="text-yellow-400">function(el, i, l) {</span>
<span class="text-purple-700"> return</span> (l - i) * 100;
<span class="text-blue-600">}</span> }); </pre>
</div>
</div
});>
</div>
`,
`<div class="w-3/4 flex justify-center">
<div id="innerSourceCodeAnimeJs" class="relative flex p-2 w-full h-42 z-10 animate__animated animate__zoomInDown border-8 ring ring-rose-500 border-double">
<div class="w-2/4 p-2 bg-blue-600/20 text-2xl text-white">
<h2 class="text-white"><<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">function-based-params-demo</span>">
<h2 class="text-white"><<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">autoplay-true</span>"> <<span class="text-yellow-600">/div</span>></h2>
<h2 class="text-white"><<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">autoplay-false</span>"> <<span class="text-yellow-600">/div</span>></h2>
<h2 class="text-white"><<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">autoplay-true</span>">
<<span class="text-yellow-600">/div</span>></h2>
<<span class="text-yellow-600">/div</span>></h2>
</div>
<div class="w-2/4 bg-blue-600/20">
<pre><span class="text-blue-800">anime</span>({
<span class="text-green-600"> targets:</span> <span class="text-yellow-400">'.autoplay-true'</span>,
<span class="text-green-600">translateX:</span><span class="text-yellow-400"> 200,</span>
<span class="text-green-600">autoplay:</span> <span class="text-yellow-400">'true',</span>
<span class="text-green-600">easing:</span><span class="text-yellow-400"> 'easeInOutSine'</span><span class="text-black">})</span>
<span class="text-blue-800">anime</span>({
<span class="text-green-600"> targets:</span> <span class="text-yellow-400">'.autoplay-true'</span>,
<span class="text-green-600">translateX:</span><span class="text-yellow-400"> 200,</span>
<span class="text-green-600">autoplay:</span> <span class="text-yellow-400">'true',</span>
<span class="text-green-600">easing:</span><span class="text-yellow-400"> 'easeInOutSine'</span><span class="text-black">})</span> </pre>
</div>
</div>
</div>`,
`
<div class="w-3/4 flex justify-center">
<div id="innerSourceCodeAnimeJs" class="relative flex p-2 w-full h-42 z-10 animate__animated animate__zoomInDown bg-slate-200/30 border-8 ring ring-rose-500 border-double">
<div class="w-2/4 p-2 bg-yellow-700/10 text-white h-auto">
<h2 class="text-white"><<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">css-transforms-demo</span>">
<h2 class="text-white"><<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">el</span>">
<<span class="text-yellow-600">/div</span>></h2>
<<span class="text-yellow-600">/div</span>></h2>
</div>
<div class="w-2/4 bg-yellow-700/10">
<pre><span class="text-blue-800">anime</span>({
<span class="text-green-600"> targets:</span> <span class="text-yellow-400">'.css-transforms-demo .el'</span>,
<span class="text-green-600">translateX:</span><span class="text-yellow-400"> 180,</span>
<span class="text-green-600">scale:</span> <span class="text-yellow-400">'2',</span>
<span class="text-green-600">rotate:</span><span class="text-yellow-400"> 1turn,</span>
</pre>
</div>
</div>
</div>
`,
`
<div class="div w-3/4 flex absolute justify-center">
<div id="innerSourceCodeAnimeJs" class="relative flex p-2 w-full h-5/6 z-10 animate__animated animate__zoomInDown bg-slate-200/30 border-8 ring ring-rose-500 border-double">
<div class="w-2/4 p-2 bg-green-600/10 text-white text-2xl">
<h2 class="text-white"><<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">motion-path-demo</span>">
<h2 class="text-white"><<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">el follow-path</span>"> <<span class="text-yellow-600">/div</span>></h2>
<h2 class="text-white"><<span class="text-yellow-600">svg</span> <span class="text-yellow-400"> width=</span>"<span class="text-green-700">256</span>" <span class="text-yellow-400"> height=</span>"<span class="text-green-700">112</span>">
<br>< <span class="text-yellow-600">path</span>> <<span class="text-yellow-600">path</span>> <<span class="text-yellow-600">/svg</span>></h2>
<<span class="text-yellow-600">/div</span>></h2>
</div>
<div class="w-2/4 bg-green-600/10 text-xg ">
<pre>
<span class="text-rose-400">let</span><span class="text-white"> path</span><span class="text-blue-400">=</span>anime.<span class="text-blue-600">path</span><span class="text-green-700">('.motion-path-demo path')</span>
<span class="text-blue-800">anime</span>({
<span class="text-green-600"> targets:</span> <span class="text-yellow-400">'.motion-path-demo .el'</span>,
<span class="text-green-600">translateX:</span><span class="text-yellow-400"> path('x'),</span>
<span class="text-green-600">translateY</span> <span class="text-yellow-400">path('y'),</span>
<span class="text-green-600">rotate:</span><span class="text-yellow-400"> path('angle')</span>
<span class="text-green-600"> easing:</span> <span class="text-yellow-400">'linear',</span>
<span class="text-green-600">duration:</span><span class="text-yellow-700"> 2000,</span>;
<span class="text-green-600">loop:</span><span class="text-yellow-700"> true,</span>;
<span class="text-yellow-400">})</span>
</pre>
</div>
</div>
</div>
`,
//4
`
<div class="div w-3/4 flex absolute justify-center">
<div id="innerSourceCodeAnimeJs" class="relative flex p-2 w-full h-42 z-10 animate__animated animate__zoomInDown bg-slate-200/30 border-8 ring ring-rose-500 border-double">
<div class="w-2/4 p-2 bg-rose-600/20 text-white h-auto">
<h2 class="text-white"><<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">staggering-grid-demo</span>">
<h2 class="text-white"> <<span class="text-yellow-600">div</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700"/>grid grid-cols-12 bg-gray-600</span>"> <div class="w-5 h-5 bg-red-600 border border-white ssmall square el" style="transform: scale(1);"></div> <<span class="text-yellow-600">/div</span>></h2>
<h2 class="text-white"><<span class="text-yellow-600">svg</span> <span class="text-yellow-400"> width=</span>"<span class="text-green-700">256</span>" <span class="text-yellow-400"> height=</span>"<span class="text-green-700">112</span>">
<br>< <span class="text-yellow-600">path</span>> <<span class="text-yellow-600">path</span>> <<span class="text-yellow-600">/svg</span>></h2>
<<span class="text-yellow-600">/div</span>></h2>
</div>
<div class="w-2/4 bg-rose-600/20 text-lg h-auto">
<pre>
<span class="text-rose-400">let</span><span class="text-white"> path</span><span class="text-blue-400">=</span>anime.<span class="text-blue-600">path</span><span class="text-green-700">('.motion-path-demo path')</span>
<span class="text-blue-800">anime</span>({
<span class="text-green-600"> targets:</span> <span class="text-yellow-400">'.motion-path-demo .el'</span>,
<span class="text-green-600">translateX:</span><span class="text-yellow-400"> path('x'),</span>
<span class="text-green-600">translateY</span> <span class="text-yellow-400">path('y'),</span>
<span class="text-green-600">rotate:</span><span class="text-yellow-400"> path('angle')</span>
<span class="text-green-600"> easing:</span> <span class="text-yellow-400">'linear',</span>
<span class="text-green-600">duration:</span><span class="text-yellow-700"> 2000,</span>;
<span class="text-green-600">loop:</span><span class="text-yellow-700"> true,</span>;
<span class="text-yellow-400">})</span>
</pre>
</div>
</div>
</div>
`,
];
function animateCss() {
//TODO -------------------------------------------------------------------------- */
//? --------------------------------- moveBorder ------------------------------- */
//TODO -------------------------------------------------------------------------- */
let elmTitle = document.querySelector(".title");
let offsetTitle = anime.setDashoffset(elmTitle);
elmTitle.setAttribute("stroke-dashoffset", offsetTitle);
anime({
targets: elmTitle,
strokeDashoffset: [offsetTitle, 200],
duration: anime.random(1000, 3000),
delay: anime.random(0, 0),
loop: true,
direction: "alternate",
easing: "easeInOutSine",
autoplay: true,
});
//TODO -------------------------------------------------------------------------- */
//? ------------------------------ TheMoveBorder ------------------------------- */
//TODO -------------------------------------------------------------------------- */
//* -------------------------------------------------------------------------- */
//! ------------------------------ StartAnimate.css ------------------------------ */
//* -------------------------------------------------------------------------- */
let elmAnimate = document.querySelector(".layer2");
let offsetAnimate = anime.setDashoffset(elmAnimate);
elmAnimate.setAttribute("stroke-dashoffset", offsetAnimate);
anime({
targets: elmAnimate,
strokeDashoffset: [offsetAnimate, 25],
duration: anime.random(3000, 2000),
delay: anime.random(1000, 1000),
loop: true,
direction: "alternate",
easing: "easeInOutSine",
autoplay: true,
});
//* -------------------------------------------------------------------------- */
//! ------------------------------ TheEndAnimate.css ------------------------------ */
//* -------------------------------------------------------------------------- */
//! -------------------------------------------------------------------------- */
//* ----------------------------- ClassAnimation.css ----------------------------- */
//! -------------------------------------------------------------------------- */
let ArrayListMove = [
"animate__bounce",
"animate__flash",
"animate__pulse",
"animate__rubberBand",
"animate__shakeX",
"animate__shakeY",
"animate__headShake",
"animate__swing",
"animate__tada",
"animate__wobble",
"animate__jello",
"animate__heartBeat",
"animate__backInDown",
"animate__backInLeft",
"animate__backInRight",
"animate__backInUp",
"animate__backOutDown",
"animate__backOutLeft",
"animate__backOutRight",
"animate__backOutUp",
"animate__bounceIn",
"animate__bounceInDown",
"animate__bounceInLeft",
"animate__bounceInRight",
"animate__bounceInUp",
"animate__fadeIn",
"animate__fadeInDownBig",
"animate__flipInX",
"animate__lightSpeedInLeft",
"animate__rotateInDownLeft",
];
let elemTextView = document.querySelector(".textView");
let elemListMove = document.querySelectorAll(".list_move > div > a");
let elemAnimateCss = document.querySelector(".animateCss");
for (let i = 0; i < ArrayListMove.length; i++) {
elemListMove[i].onclick = () => {
elemTextView.innerHTML = `<h2 class="text-white"><<span class="text-yellow-600">h1</span> <span class="text-yellow-400"> class=</span>"<span class="text-green-700">animate__animated ${ArrayListMove[i]}</span>"> Animate.css <<span class="text-yellow-600">/h1</span>></h2> `;
handler(elemAnimateCss, ArrayListMove[i], 800);
};
}
//! -------------------------------------------------------------------------- */
//* -------------------------- TheEndClassAnimation.css ----------------------------- */
//! -------------------------------------------------------------------------- */
//TODO ----------------------- FunctionViewClassAnimation ----------------------- */
function handler(element, moveAnimate, time) {
element.classList.toggle(moveAnimate);
setTimeout(() => {
element.classList.remove(moveAnimate);
}, time);
}
}
function animateJs() {
//! -------------------------------------------------------------------------- */
//* ----------------------------- StartAnimate.js ----------------------------- */
//! -------------------------------------------------------------------------- */
let elmAnimateJs = document.querySelector(".animate_js");
let elmContainerSvgAnimeJs = document.querySelector("#container-Svg-AnimeJs");
let containerAnimateJs = document.querySelector("#Code-svgAnimateJs");
let offsetAnimateJs = anime.setDashoffset(elmAnimateJs);
function SvgAnimateJs() {
elmAnimateJs.setAttribute("stroke-dashoffset", offsetAnimateJs);
anime({
targets: elmAnimateJs,
strokeDashoffset: [offsetAnimateJs, 25],
duration: anime.random(3000, 2000),
delay: anime.random(1000, 0),
loop: true,
direction: "alternate",
easing: "easeInOutSine",
autoplay: true,
});
}
containerAnimateJs.addEventListener("click", () => {
console.log("containeAnimeJs");
// elmContainerSvgAnimeJs.classList.add("hidden");
elmTextAnimeJs.innerHTML = "";
elmTextAnimeJs.insertAdjacentHTML(
"beforeend",
`
<div class="absolute w-5/6 h-5/6 flex justify-center divAnimateJs animate__animated animate__lightSpeedInLeft">
<svg class="w-full" viewBox="100 0 245 100" xmlns="http://www.w3.org/2000/svg">
<defs></defs>
<text class="animate_js animate__animated" style="fill: rgb(235, 14, 14); font-family: "Distro Extinct"; stroke: rgb(124, 132, 97); stroke-dasharray: 30px; stroke-dashoffset: 3.37319px; stroke-opacity: 0.53; stroke-width: 0.756387px; white-space: pre;" transform="matrix(4.114889, 0, 0, 3.817554, -392.250885, -53.289532)" x="119.835" y="32.323" stroke-dasharray="undefined">AnimeJs</text>
</svg>
`,
);
location.reload();
// sourceCodeAnimJs.remove();
});
SvgAnimateJs();
//TODO --------------- scrollAnimateJs ----------------- */
// let body = document.body;
let elmDivAnimateJs = document.querySelector(".divAnimateJs");
let elmLineAnimate = document.querySelector("#lineAnimate");
window.onscroll = () => {
winScroll(384, elmLineAnimate, "animate__backInRight"); //! <=== جواب
winScroll(845, elmDivAnimateJs, "animate__lightSpeedInLeft");
};
//TODO --------------- TheEndScrollAnimateJs ----------------- */
//@
//! -------------------------------------------------------------------------- */
//* ----------------------------- MenuAnimeJs -------------------------------- */
//! -------------------------------------------------------------------------- */
let elmMenuCodeAnimeJs = document.querySelector("#menuCodeAnimeJs");
let sourceCodeAnimJs = document.querySelector("#innerSourceCodeAnimeJ");
//TODO --------------- animeJs-1 ----------------- */
let elemAnimeJs_1 = document.querySelector("#animejs-1");
let elmTextAnimeJs = document.querySelector(".divMenuAnimeJs");
let elmDivAnimeJs = document.querySelector("#divAll");
let createElm = document.createElement("div");
elemAnimeJs_1.addEventListener("click", animeJs_1);
let elmEl = document.querySelectorAll(".el");
function animeJs_1() {
createElm.classList =
"relative bottom-56 w-3/4 h-52 animate__animated animate__zoomInDown bg-slate-200/30 border-8 ring ring-rose-500 border-double";
elmDivAnimeJs.classList.remove("mt-52");
elmDivAnimeJs.classList.add("mt-2");
elmTextAnimeJs.innerHTML = "";
////! source code anime js
elmTextAnimeJs.insertAdjacentHTML("beforeend", codeAnmieJs_All[0]);
//!2test replay click fix animate
anime({
targets: ".function-based-params-anime-js .el",
translateX: 190,
direction: "alternate",
loop: true,
delay: function (el, i, l) {
return i * 500;
},
endDelay: function (el, i, l) {
return (l - i) * 100;
},
});
}
//TODO --------------- animeJs-2 ----------------- */
let elementAnimeJS_2 = document.querySelector("#animejs-2");
elementAnimeJS_2.addEventListener("click", clickAnimejs_2);
function clickAnimejs_2() {
createElm.classList =
"relative bottom-56 w-3/4 h-52 animate__animated animate__zoomInDown bg-slate-200/30 border-8 ring ring-rose-500 border-double";
elmDivAnimeJs.classList.remove("mt-52");
elmDivAnimeJs.classList.add("mt-2");
elmTextAnimeJs.innerHTML = "";
////! source code anime js
elmTextAnimeJs.insertAdjacentHTML("beforeend", codeAnmieJs_All[1]);
//! fix Repaly Fix
//
anime({
targets: ".autoplay-true",
translateX: 180,
autoplay: true,
easing: "easeInOutSine",
loop: true,
});
anime({
targets: ".autoplay-true",
translateX: 200,
autoplay: false,
easing: "easeInOutSine",
});
}
//TODO --------------- animeJs-3 ----------------- */
let elementAnimeJS_3 = document.querySelector("#animejs-3");
elementAnimeJS_3.addEventListener("click", clickAnimejs_3);
function clickAnimejs_3() {
createElm.classList =
"relative bottom-56 w-3/4 h-52 animate__animated animate__zoomInDown bg-slate-200/30 border-8 ring ring-rose-500 border-double";
elmDivAnimeJs.classList.remove("mt-52");
elmDivAnimeJs.classList.add("mt-2");
elmTextAnimeJs.innerHTML = "";
////! source code anime js
elmTextAnimeJs.insertAdjacentHTML("beforeend", codeAnmieJs_All[2]);
//! fix Repaly Fix
var progressLogEl = document.querySelector(".promise-demo .progress-log");
var promiseEl = document.querySelector(".promise-demo .el");
var finishedLogEl = document.querySelector(".promise-demo .finished-log");
var demoPromiseResetTimeout;
function logFinished() {
anime.set(finishedLogEl, { value: "Promise resolved" });
anime.set(promiseEl, { backgroundColor: "#18FF92" });
}
var animation = anime
.timeline({
targets: promiseEl,
delay: 400,
duration: 380,
endDelay: 400,
easing: "easeInOutSine",
update: function (anim) {
progressLogEl.value = "progress : " + Math.round(anim.progress) + "%";
},
})
.add({ translateX: 180 })
.add({ scale: 2 })
.add({ translateX: 0 });
animation.finished.then(logFinished);
}
//TODO --------------- animeJs-4 ----------------- */
let path = anime.path(".motion-path-demo path");
let elementAnimeJS_4 = document.querySelector("#animejs-4");
elementAnimeJS_4.addEventListener("click", clickAnimejs_4);
function clickAnimejs_4() {
createElm.classList =
"relative bottom-56 w-3/4 h-52 animate__animated animate__zoomInDown bg-slate-200/30 border-8 ring ring-rose-500 border-double";
elmDivAnimeJs.classList.remove("mt-52");
elmDivAnimeJs.classList.add("mt-2");
elmTextAnimeJs.innerHTML = "";
////! source code anime js
elmTextAnimeJs.insertAdjacentHTML("beforeend", codeAnmieJs_All[3]);
let path = anime.path(".motion-path-demo path");
anime({
targets: ".motion-path-demo .el",
translateX: path("x"),
translateY: path("y"),
rotate: path("angle"),
easing: "linear",
duration: 2000,
loop: true,
});
}
//TODO --------------- animeJs-5 ----------------- */
let elementAnimeJS_5 = document.querySelector("#animejs-5");
elementAnimeJS_5.addEventListener("click", clickAnimejs_5);
function clickAnimejs_5() {
createElm.classList =
"relative bottom-56 w-3/4 h-52 animate__animated animate__zoomInDown bg-slate-200/30 border-8 ring ring-rose-500 border-double";
elmDivAnimeJs.classList.remove("mt-52");
elmDivAnimeJs.classList.add("mt-2");
elmTextAnimeJs.innerHTML = "";
////! source code anime js
elmTextAnimeJs.insertAdjacentHTML("beforeend", codeAnmieJs_All[4]);
anime({
targets: ".staggering-grid-demo .el",
scale: [
{ value: 0.1, easing: "easeOutSine", duration: 500 },
{ value: 1, easing: "easeInOutQuad", duration: 1200 },
],
delay: anime.stagger(200, { grid: [14, 5], from: "center" }),
});
// }
}
//TODO --------------- animeJs-6 ----------------- */
var animation = anime({
targets: ".seek-anim-demo .el",
translateX: 180,
delay: function (el, i) {
return i * 100;
},
elasticity: 200,
easing: "easeInOutSine",
autoplay: false,
});
var seekProgressEl = document.querySelector(".seek-anim-demo .progress");
seekProgressEl.oninput = function () {
animation.seek(animation.duration * (seekProgressEl.value / 100));
};
function menuAnimeJs(colorBorder, colorBg, colorShadow) {
let elmAll_Menu = document.querySelectorAll(".menuAnimeJs");
for (let i = 0; i < elmAll_Menu.length; i++) {}
}
//TODO --------------- animeJs-7 ----------------- */
// Wrap every letter in a span
var textWrapper = document.querySelector(".ml1 .letters");
textWrapper.innerHTML = textWrapper.textContent.replace(
/\S/g,
"<span class='letter'>$&</span>",
);
anime
.timeline({ loop: true })
.add({
targets: ".ml1 .letter",
scale: [0.3, 1],
opacity: [0, 1],
translateZ: 0,
easing: "easeOutExpo",
duration: 600,
delay: (el, i) => 70 * (i + 1),
})
.add({
targets: ".ml1 .line",
scaleX: [0, 1],
opacity: [0.5, 1],
easing: "easeOutExpo",
duration: 700,
offset: "-=875",
delay: (el, i, l) => 80 * (l - i),
})
.add({
targets: ".ml1",
opacity: 0,
duration: 1000,
easing: "easeOutExpo",
delay: 1000,
});
}
function moJs() {
//!====>move moJs <=====\\
let scr = window.scrollY;
let ElmMoveJs = document.querySelector("#moveMoJs");
window.addEventListener("scroll", () => {
if (1818 < window.scrollY) console.log("test good scroll");
anime({
targets: "#moveMoJs",
translateX: 500,
autoplay: "false",
easing: "easeInOutSine",
});
anime({
targets: "#moveMoJs2",
translateX: -500,
autoplay: "false",
easing: "easeInOutSine",
});
});
//! move Mo.js \\
//? ======> MoveJs <======\\
new mojs.Shape({
parent: "#circle",
shape: "circle", // shape 'circle' is default
radius: 25, // shape radius
radiusX: 30,
left: "25%",
isShowStart: true, // show before any animation starts
});
new mojs.Shape({
parent: "#polygon",
shape: "polygon", // shape 'polygon' and rect
radius: 35, // shape radius
radiusX: 60,
left: "25%",
fill: "yellow", // same as 'transparent'
stroke: "black", // or 'cyan'
strokeWidth: 4, // width of the stroke
isShowStart: true, // show before any animation starts
});
new mojs.Shape({
parent: "#zigzag",
shape: "zigzag",
points: 8,
radius: 130,
radiusY: 50,
left: "45%",
top: "60%",
fill: "none",
stroke: "blue",
isShowStart: true,
});
new mojs.Shape({
parent: "#cross",
shape: "cross",
points: 11,
radius: 65,
radiusX: 95,
left: "75%",
stroke: "green",
isShowStart: true,
strokeWidth: 4,
});
const circleCopy = document.querySelector("#Layer_1");
circleCopy.addEventListener("click", () => {
ClipboardEvent;
navigator.clipboard.writeText(`"
<div class="relative bg-black/20 h-28 ">
<div id="bouncyCircle2" class="absolute top-10 left-1/2 w-4 h-8" ></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/@mojs/core"></script>
<script>
const bouncyCircle2 = new mojs.Shape({
parent: "#bouncyCircle2",
shape: "circle",
fill: { "#F64040": "#FC46AD" },
radius: { 20: 40 },
duration: 2000,
isYoyo: true,
isShowStart: true,
easing: "elastic.inout",
repeat: 100,
});
bouncyCircle2.play();
</script>`);
});
const bouncyCircle = new mojs.Shape({
parent: "#bouncyCircle",
shape: "circle",
fill: { "#d98d6c": "#fa4d02" },
radius: { 20: 80 },
duration: 2000,
isYoyo: true,
isShowStart: true,
easing: "elastic.inout",
repeat: 100,
});