-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
1310 lines (1170 loc) · 43.9 KB
/
script.js
File metadata and controls
1310 lines (1170 loc) · 43.9 KB
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
// Wait for DOM to be fully loaded
document.addEventListener('DOMContentLoaded', function() {
// Initialize slides first
initSlides();
// Then initialize other animations
if (typeof gsap !== 'undefined') {
initAnimations();
}
});
// Slides Presentation System
function initSlides() {
const slidesContainer = document.getElementById('slidesContainer');
if (!slidesContainer) return;
// Get all slides directly from container
const allSlides = slidesContainer.querySelectorAll('.slide');
if (!allSlides || allSlides.length === 0) return;
// Convert to array and sort by data-slide
const slides = Array.from(allSlides).sort((a, b) => {
const aNum = parseInt(a.getAttribute('data-slide')) || 999;
const bNum = parseInt(b.getAttribute('data-slide')) || 999;
return aNum - bNum;
});
const prevButton = document.getElementById('prevSlide');
const nextButton = document.getElementById('nextSlide');
const currentSlideEl = document.getElementById('currentSlide');
const totalSlidesEl = document.getElementById('totalSlides');
if (!prevButton || !nextButton || !currentSlideEl || !totalSlidesEl) return;
let currentSlideIndex = 0;
const totalSlides = slides.length;
totalSlidesEl.textContent = totalSlides;
// Function to show a specific slide
function showSlide(index) {
slides.forEach((slide, i) => {
if (i === index) {
slide.style.display = 'block';
slide.style.opacity = '1';
slide.style.visibility = 'visible';
slide.style.transform = 'translateX(0)';
slide.style.zIndex = '10';
slide.classList.add('active');
} else {
slide.style.display = 'none';
slide.style.opacity = '0';
slide.style.visibility = 'hidden';
slide.style.transform = 'translateX(100%)';
slide.style.zIndex = '0';
slide.classList.remove('active');
}
});
}
// Initialize - show first slide
showSlide(0);
setTimeout(() => {
animateSlideContent(slides[0]);
}, 100);
updateSlideCounter();
updateNavButtons();
// Initialize navigation
initNavigation(slides);
updateNavigation();
// Animate slide content when slide becomes active
function animateSlideContent(slide) {
if (typeof gsap === 'undefined') {
// Fallback if GSAP not loaded
const elements = slide.querySelectorAll('.section-title, .hero-title, .hero-subtitle, .logo, .philosophy-card, .criterion-item, .tab-content, .life-example-card, .comparison-table, .decision-card, .cta-button');
elements.forEach((el) => {
el.style.opacity = '1';
el.style.transform = 'translateY(0)';
});
return;
}
// Hero slide specific animations
if (slide.classList.contains('hero')) {
const logos = slide.querySelectorAll('.logo');
const titleLines = slide.querySelectorAll('.hero-title .title-line');
const subtitle = slide.querySelector('.hero-subtitle');
gsap.set([...logos, ...titleLines, subtitle], { opacity: 0, y: 30 });
gsap.to(logos, {
opacity: 1,
scale: 1,
y: 0,
duration: 0.8,
stagger: 0.2,
ease: 'back.out(1.7)'
});
gsap.to(titleLines, {
opacity: 1,
y: 0,
duration: 0.6,
stagger: 0.1,
delay: 0.3,
ease: 'power3.out'
});
gsap.to(subtitle, {
opacity: 1,
y: 0,
duration: 0.6,
delay: 0.5,
ease: 'power2.out'
});
} else {
// Other slides - animate section title and content
const sectionTitle = slide.querySelector('.section-title');
const introText = slide.querySelectorAll('.intro-text, .intro-question');
const contentWrapper = slide.querySelector('.content-wrapper');
const criterionTitle = slide.querySelector('.criterion-title');
const contentElements = slide.querySelectorAll('.philosophy-card, .criterion-item, .tab-content, .life-example-card, .decision-card, .cta-button, .comparison-table, .example-task-layout, .life-example-layout, .container > *:not(.section-title):not(.section-grid):not(.section-background):not(.floating-elements):not(.section-connector)');
if (sectionTitle) {
gsap.from(sectionTitle, {
opacity: 0,
y: -30,
duration: 0.6,
ease: 'power3.out'
});
}
if (criterionTitle) {
gsap.from(criterionTitle, {
opacity: 0,
y: -20,
duration: 0.5,
delay: 0.2,
ease: 'power2.out'
});
}
// Animate intro text and content wrapper
if (contentWrapper) {
const texts = contentWrapper.querySelectorAll('.intro-text, .intro-question');
if (texts.length > 0) {
texts.forEach((text, i) => {
gsap.set(text, { opacity: 0, y: 20 });
gsap.to(text, {
opacity: 1,
y: 0,
duration: 0.6,
delay: 0.3 + (i * 0.1),
ease: 'power2.out'
});
});
} else {
gsap.set(contentWrapper, { opacity: 0, y: 20 });
gsap.to(contentWrapper, {
opacity: 1,
y: 0,
duration: 0.6,
delay: 0.3,
ease: 'power2.out'
});
}
} else if (introText.length > 0) {
introText.forEach((text, i) => {
gsap.set(text, { opacity: 0, y: 20 });
gsap.to(text, {
opacity: 1,
y: 0,
duration: 0.6,
delay: 0.3 + (i * 0.1),
ease: 'power2.out'
});
});
}
contentElements.forEach((el, i) => {
if (el && el.offsetParent !== null && !el.classList.contains('content-wrapper')) { // Only visible elements
gsap.from(el, {
opacity: 0,
y: 30,
duration: 0.5,
delay: 0.3 + (i * 0.05),
ease: 'power2.out'
});
}
});
}
}
// Go to slide function
function goToSlide(index) {
if (index < 0 || index >= totalSlides) return;
if (index === currentSlideIndex) return;
currentSlideIndex = index;
showSlide(index);
// Animate content
setTimeout(() => {
animateSlideContent(slides[index]);
}, 100);
updateSlideCounter();
updateNavButtons();
updateNavigation();
}
// Initialize navigation menu
function initNavigation(slidesArray) {
const navList = document.getElementById('navList');
const navToggle = document.getElementById('navToggle');
const dropdownNav = document.getElementById('dropdownNav');
const navToggleText = navToggle.querySelector('.nav-toggle-text');
let isNavOpen = false;
if (!navList || !navToggle || !dropdownNav) return;
// Clear existing navigation
navList.innerHTML = '';
// Slide names mapping
const slideNames = {
'hero': 'Главная',
'introduction': 'Введение',
'philosophy': 'Философия',
'comparison-1': 'Сравнение 1',
'comparison-2': 'Сравнение 2',
'comparison-3': 'Сравнение 3',
'comparison-4': 'Сравнение 4',
'example-task-matlab': 'Пример MATLAB',
'example-task-maple': 'Пример Maple',
'example-task-mathcad': 'Пример MathCad',
'real-life-examples-1': 'Пример MATLAB',
'real-life-examples-2': 'Пример Maple',
'real-life-examples-3': 'Пример MathCad',
'summary': 'Сводная таблица',
'conclusion': 'Заключение',
'thank-you': 'Спасибо'
};
// Create navigation items
slidesArray.forEach((slide, index) => {
const slideId = slide.id;
const slideName = slideNames[slideId] || slideId;
const slideNumber = index + 1;
const li = document.createElement('li');
const a = document.createElement('a');
a.href = `#${slideId}`;
a.className = 'nav-link';
a.setAttribute('data-slide-index', index);
a.textContent = `${slideNumber}. ${slideName}`;
a.addEventListener('click', (e) => {
e.preventDefault();
goToSlide(index);
});
li.appendChild(a);
navList.appendChild(li);
});
// Toggle navigation
function toggleNav() {
isNavOpen = !isNavOpen;
dropdownNav.classList.toggle('active');
if (isNavOpen) {
navToggleText.textContent = 'Скрыть навигацию';
} else {
navToggleText.textContent = 'Показать навигацию';
}
}
navToggle.addEventListener('click', (e) => {
e.stopPropagation();
toggleNav();
});
// Close nav when clicking outside
document.addEventListener('click', (e) => {
if (isNavOpen && !dropdownNav.contains(e.target) && !navToggle.contains(e.target)) {
toggleNav();
}
});
}
// Update active navigation link
function updateNavigation() {
const navLinks = document.querySelectorAll('.nav-link');
navLinks.forEach((link, index) => {
link.classList.remove('active');
if (index === currentSlideIndex) {
link.classList.add('active');
}
});
}
// Update slide counter
function updateSlideCounter() {
currentSlideEl.textContent = currentSlideIndex + 1;
}
// Update navigation buttons
function updateNavButtons() {
prevButton.disabled = currentSlideIndex === 0;
nextButton.disabled = currentSlideIndex === totalSlides - 1;
}
// Previous slide
prevButton.addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation();
if (currentSlideIndex > 0) {
goToSlide(currentSlideIndex - 1);
}
});
// Next slide
nextButton.addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation();
if (currentSlideIndex < totalSlides - 1) {
goToSlide(currentSlideIndex + 1);
}
});
// Keyboard navigation
document.addEventListener('keydown', (e) => {
if (e.key === 'ArrowLeft' && currentSlideIndex > 0) {
e.preventDefault();
goToSlide(currentSlideIndex - 1);
} else if (e.key === 'ArrowRight' && currentSlideIndex < totalSlides - 1) {
e.preventDefault();
goToSlide(currentSlideIndex + 1);
}
});
// Touch/swipe support (optional)
let touchStartX = 0;
let touchEndX = 0;
document.addEventListener('touchstart', (e) => {
touchStartX = e.changedTouches[0].screenX;
});
document.addEventListener('touchend', (e) => {
touchEndX = e.changedTouches[0].screenX;
handleSwipe();
});
function handleSwipe() {
const swipeThreshold = 50;
const diff = touchStartX - touchEndX;
if (Math.abs(diff) > swipeThreshold) {
if (diff > 0 && currentSlideIndex < totalSlides - 1) {
// Swipe left - next slide
goToSlide(currentSlideIndex + 1);
} else if (diff < 0 && currentSlideIndex > 0) {
// Swipe right - previous slide
goToSlide(currentSlideIndex - 1);
}
}
}
}
function initAnimations() {
// Register GSAP ScrollTrigger plugin
if (typeof gsap === 'undefined' || typeof ScrollTrigger === 'undefined') {
console.error('GSAP or ScrollTrigger not loaded');
return;
}
gsap.registerPlugin(ScrollTrigger);
// Disable smooth scrolling for slides
document.documentElement.style.scrollBehavior = 'auto';
// Hero Section Animations
const heroTimeline = gsap.timeline();
// Set initial state for logos
gsap.set('.logo', { opacity: 0, scale: 0 });
// Animate logos on load
heroTimeline.to('.logo', {
opacity: 1,
scale: 1,
rotation: 0,
duration: 1.2,
ease: 'back.out(1.7)',
stagger: 0
});
// Animate title
heroTimeline.from('.hero-title .title-line', {
opacity: 0,
y: 50,
duration: 0.8,
stagger: 0,
ease: 'power3.out'
}, '-=0.5');
// Animate subtitle
heroTimeline.from('.hero-subtitle', {
opacity: 0,
y: 30,
duration: 0.8,
ease: 'power2.out'
}, '-=0.3');
// Animate scroll indicator
heroTimeline.from('.scroll-indicator', {
opacity: 0,
duration: 0.6,
ease: 'power2.out'
}, '-=0.2');
// Logo morphing animation (continuous)
const logos = document.querySelectorAll('.logo');
let currentLogo = 0;
function morphLogos() {
logos.forEach((logo, index) => {
if (index === currentLogo) {
gsap.to(logo, {
scale: 1.15,
duration: 0.5,
ease: 'power2.inOut'
});
} else {
gsap.to(logo, {
scale: 1,
duration: 0.5,
ease: 'power2.inOut'
});
}
});
currentLogo = (currentLogo + 1) % logos.length;
}
// Start morphing after initial animation
setTimeout(() => {
setInterval(morphLogos, 3000);
}, 2000);
// Parallax effect for background symbols in hero
gsap.to('.hero .symbol', {
y: (i, el) => {
return ScrollTrigger.maxScroll(window) * 0.3;
},
ease: 'none',
scrollTrigger: {
trigger: '.hero',
start: 'top top',
end: 'bottom top',
scrub: true
}
});
// Color animation for symbols - make them change color on scroll
const allSymbols = document.querySelectorAll('.symbol');
allSymbols.forEach((symbol, index) => {
// Create scroll-based color animation
ScrollTrigger.create({
trigger: document.body,
start: 'top top',
end: 'bottom bottom',
scrub: true,
onUpdate: (self) => {
const progress = self.progress;
let color;
if (progress < 0.33) {
// MATLAB blue to Maple red
const t = progress / 0.33;
color = gsap.utils.interpolate('#0076A5', '#D50000', t);
} else if (progress < 0.66) {
// Maple red to Mathcad green
const t = (progress - 0.33) / 0.33;
color = gsap.utils.interpolate('#D50000', '#00A859', t);
} else {
// Mathcad green back to MATLAB blue
const t = (progress - 0.66) / 0.34;
color = gsap.utils.interpolate('#00A859', '#0076A5', t);
}
symbol.style.color = color;
// Also animate opacity based on scroll
const opacity = 0.08 + (Math.sin(progress * Math.PI * 2) * 0.07);
symbol.style.opacity = opacity;
}
});
// Parallax effect for symbols
gsap.to(symbol, {
y: ScrollTrigger.maxScroll(window) * (0.05 + (index % 3) * 0.02),
rotation: 180,
ease: 'none',
scrollTrigger: {
trigger: document.body,
start: 'top top',
end: 'bottom bottom',
scrub: true
}
});
});
// Make floating elements change color on scroll
const floatingElements = document.querySelectorAll('.floating-element');
floatingElements.forEach((el, index) => {
ScrollTrigger.create({
trigger: document.body,
start: 'top top',
end: 'bottom bottom',
scrub: true,
onUpdate: (self) => {
const progress = self.progress;
const colorType = el.getAttribute('data-color');
let opacity;
if (colorType === 'matlab') {
opacity = 0.1 + Math.sin(progress * Math.PI * 2 + index) * 0.1;
} else if (colorType === 'maple') {
opacity = 0.1 + Math.sin(progress * Math.PI * 2 + index + 1) * 0.1;
} else {
opacity = 0.1 + Math.sin(progress * Math.PI * 2 + index + 2) * 0.1;
}
el.style.opacity = opacity;
// Scale based on scroll
const scale = 1 + Math.sin(progress * Math.PI * 4) * 0.2;
el.style.transform = `scale(${scale})`;
}
});
});
// Animate connector lines with color changes and movement
const connector = document.getElementById('symbol-connector');
if (connector) {
const svg = connector.querySelector('.connector-svg');
const paths = connector.querySelectorAll('.connector-path');
const gradient = connector.querySelector('#connectorGradient');
// Make SVG scale with page height
const updateSVGHeight = () => {
const pageHeight = document.documentElement.scrollHeight;
if (svg) {
svg.setAttribute('viewBox', `0 0 100 ${pageHeight / 10}`);
svg.style.height = `${pageHeight}px`;
}
};
updateSVGHeight();
window.addEventListener('resize', updateSVGHeight);
paths.forEach((path, index) => {
// Animate dash offset for flowing effect
gsap.to(path, {
strokeDashoffset: -100,
ease: 'none',
scrollTrigger: {
trigger: document.body,
start: 'top top',
end: 'bottom bottom',
scrub: true
}
});
});
// Animate gradient colors on scroll
ScrollTrigger.create({
trigger: document.body,
start: 'top top',
end: 'bottom bottom',
scrub: true,
onUpdate: (self) => {
const progress = self.progress;
if (gradient) {
const stops = gradient.querySelectorAll('stop');
stops.forEach((stop) => {
const offset = parseFloat(stop.getAttribute('offset'));
let color;
if (offset === 0) {
color = gsap.utils.interpolate('#0076A5', '#D50000', progress);
} else if (offset === 0.33) {
color = gsap.utils.interpolate('#D50000', '#00A859', progress);
} else if (offset === 0.66) {
color = gsap.utils.interpolate('#00A859', '#0076A5', progress);
} else {
color = gsap.utils.interpolate('#0076A5', '#D50000', progress);
}
stop.setAttribute('style', `stop-color:${color};stop-opacity:${0.1 + Math.sin(progress * Math.PI * 2) * 0.1}`);
});
}
// Animate connector opacity
if (connector) {
const opacity = 0.15 + Math.sin(progress * Math.PI * 4) * 0.1;
connector.style.opacity = opacity;
}
}
});
}
// Set initial states for introduction
gsap.set('.introduction .section-title', { opacity: 0, y: 50 });
gsap.set('.intro-text', { opacity: 0, x: -50 });
gsap.set('.intro-question', { opacity: 0, scale: 0.9 });
// Introduction Section Animation
gsap.to('.introduction .section-title', {
opacity: 1,
y: 0,
duration: 1,
ease: 'power3.out',
scrollTrigger: {
trigger: '.introduction',
start: 'top 80%',
toggleActions: 'play none none reverse'
}
});
gsap.to('.intro-text', {
opacity: 1,
x: 0,
duration: 1,
stagger: 0,
ease: 'power2.out',
scrollTrigger: {
trigger: '.introduction',
start: 'top 75%',
toggleActions: 'play none none reverse'
}
});
gsap.to('.intro-question', {
opacity: 1,
scale: 1,
duration: 0.8,
ease: 'back.out(1.7)',
scrollTrigger: {
trigger: '.intro-question',
start: 'top 80%',
toggleActions: 'play none none reverse'
}
});
// Set initial state for philosophy section title
gsap.set('.philosophy .section-title', { opacity: 0, y: 30 });
// Philosophy section title animation
gsap.to('.philosophy .section-title', {
opacity: 1,
y: 0,
duration: 0.8,
ease: 'power2.out',
scrollTrigger: {
trigger: '.philosophy',
start: 'top 80%',
toggleActions: 'play none none reverse'
}
});
// Set initial state for philosophy cards
gsap.set('.philosophy-card', { opacity: 0, y: 50 });
gsap.set('.card-icon', { opacity: 0, scale: 0, rotation: 180 });
// Philosophy Section Animation
gsap.to('.philosophy-card', {
opacity: 1,
y: 0,
duration: 0.8,
stagger: 0,
ease: 'power2.out',
scrollTrigger: {
trigger: '.philosophy-grid',
start: 'top 80%',
toggleActions: 'play none none reverse'
}
});
// Animate card icons
gsap.to('.card-icon', {
opacity: 1,
scale: 1,
rotation: 0,
duration: 0.6,
stagger: 0,
ease: 'back.out(1.7)',
scrollTrigger: {
trigger: '.philosophy-grid',
start: 'top 80%',
toggleActions: 'play none none reverse'
}
});
// Set initial state for comparison section title
gsap.set('.comparison .section-title', { opacity: 0, y: 30 });
// Comparison section title animation
gsap.to('.comparison .section-title', {
opacity: 1,
y: 0,
duration: 0.8,
ease: 'power2.out',
scrollTrigger: {
trigger: '.comparison',
start: 'top 80%',
toggleActions: 'play none none reverse'
}
});
// Comparison Section Animations
const criterionBlocks = document.querySelectorAll('.criterion-block');
criterionBlocks.forEach((block, index) => {
const title = block.querySelector('.criterion-title');
const items = block.querySelectorAll('.criterion-item');
// Set initial states with different animations for each type
gsap.set(title, { opacity: 0, y: 30 });
items.forEach((item, i) => {
if (item.classList.contains('item-matlab')) {
// MATLAB: slide from left with rotation
gsap.set(item, { opacity: 0, x: -100, rotation: -5, scale: 0.8 });
} else if (item.classList.contains('item-maple')) {
// Maple: slide from top with scale
gsap.set(item, { opacity: 0, y: -100, scale: 0.7, rotation: 5 });
} else if (item.classList.contains('item-mathcad')) {
// Mathcad: slide from bottom with bounce
gsap.set(item, { opacity: 0, y: 100, scale: 0.8, rotation: -3 });
}
});
// Animate criterion title
gsap.to(title, {
opacity: 1,
y: 0,
duration: 0.8,
ease: 'power2.out',
scrollTrigger: {
trigger: block,
start: 'top 80%',
toggleActions: 'play none none reverse'
}
});
// Animate criterion items with different animations
items.forEach((item, i) => {
if (item.classList.contains('item-matlab')) {
gsap.to(item, {
opacity: 1,
x: 0,
rotation: 0,
scale: 1,
duration: 1,
delay: 0,
ease: 'power3.out',
scrollTrigger: {
trigger: block,
start: 'top 75%',
toggleActions: 'play none none reverse'
}
});
} else if (item.classList.contains('item-maple')) {
gsap.to(item, {
opacity: 1,
y: 0,
scale: 1,
rotation: 0,
duration: 1,
delay: 0,
ease: 'back.out(1.7)',
scrollTrigger: {
trigger: block,
start: 'top 75%',
toggleActions: 'play none none reverse'
}
});
} else if (item.classList.contains('item-mathcad')) {
gsap.to(item, {
opacity: 1,
y: 0,
scale: 1,
rotation: 0,
duration: 1,
delay: 0,
ease: 'elastic.out(1, 0.5)',
scrollTrigger: {
trigger: block,
start: 'top 75%',
toggleActions: 'play none none reverse'
}
});
}
});
});
// Set initial states for example task section
gsap.set('.example-task .section-title', { opacity: 0, y: 30 });
gsap.set('.task-intro', { opacity: 0, y: 20 });
gsap.set('.solution-tabs', { opacity: 0, y: 20 });
// Set initial states for real life examples section
gsap.set('.real-life-examples .section-title', { opacity: 0, y: 30 });
gsap.set('.section-subtitle', { opacity: 0, y: 20 });
gsap.set('.life-example-card', { opacity: 0, y: 50 });
// Example Task Section Animation
gsap.to('.example-task .section-title', {
opacity: 1,
y: 0,
duration: 0.8,
ease: 'power2.out',
scrollTrigger: {
trigger: '.example-task',
start: 'top 80%',
toggleActions: 'play none none reverse'
}
});
gsap.to('.task-intro', {
opacity: 1,
y: 0,
duration: 0.8,
ease: 'power2.out',
scrollTrigger: {
trigger: '.task-intro',
start: 'top 80%',
toggleActions: 'play none none reverse'
}
});
gsap.to('.solution-tabs', {
opacity: 1,
y: 0,
duration: 0.8,
ease: 'power2.out',
scrollTrigger: {
trigger: '.solution-tabs',
start: 'top 80%',
toggleActions: 'play none none reverse'
}
});
// Real Life Examples Section Animation
gsap.to('.real-life-examples .section-title', {
opacity: 1,
y: 0,
duration: 0.8,
ease: 'power2.out',
scrollTrigger: {
trigger: '.real-life-examples',
start: 'top 80%',
toggleActions: 'play none none reverse'
}
});
gsap.to('.real-life-examples .section-subtitle', {
opacity: 1,
y: 0,
duration: 0.8,
ease: 'power2.out',
scrollTrigger: {
trigger: '.real-life-examples .section-subtitle',
start: 'top 80%',
toggleActions: 'play none none reverse'
}
});
gsap.to('.life-example-card', {
opacity: 1,
y: 0,
duration: 0.8,
stagger: 0,
ease: 'power2.out',
scrollTrigger: {
trigger: '.life-examples-grid',
start: 'top 75%',
toggleActions: 'play none none reverse'
}
});
// Tab switching functionality - fixed version
const tabButtons = document.querySelectorAll('.tab-button');
const tabContents = document.querySelectorAll('.tab-content');
function switchTab(targetTab) {
// Hide all contents first
tabContents.forEach(content => {
if (content.classList.contains('active')) {
gsap.to(content, {
opacity: 0,
y: -10,
duration: 0.2,
ease: 'power2.in',
onComplete: () => {
content.classList.remove('active');
content.style.display = 'none';
}
});
}
});
// Remove active from all buttons
tabButtons.forEach(btn => btn.classList.remove('active'));
// Activate clicked button
const clickedButton = document.querySelector(`[data-tab="${targetTab}"]`);
if (clickedButton) {
clickedButton.classList.add('active');
}
// Show target content
const targetContent = document.getElementById(`${targetTab}-tab`);
if (targetContent) {
targetContent.style.display = 'block';
targetContent.classList.add('active');
// Animate content appearance
gsap.fromTo(targetContent,
{ opacity: 0, y: 20, scale: 0.95 },
{
opacity: 1,
y: 0,
scale: 1,
duration: 0.5,
ease: 'power3.out',
delay: 0
}
);
// Animate console output
const consoleOutput = targetContent.querySelector('.console-output');
if (consoleOutput) {
const consoleLines = consoleOutput.querySelectorAll('.console-line');
gsap.fromTo(consoleLines,
{ opacity: 0, x: -30 },
{
opacity: 1,
x: 0,
duration: 0.4,
stagger: 0,
ease: 'power2.out'
}
);
}
// Animate code block
const codeBlock = targetContent.querySelector('.code-block');
if (codeBlock) {
gsap.fromTo(codeBlock,
{ opacity: 0, scale: 0.98 },
{ opacity: 1, scale: 1, duration: 0.4, ease: 'power2.out' }
);
}
}
}
tabButtons.forEach(button => {
button.addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation();
const targetTab = button.getAttribute('data-tab');
switchTab(targetTab);
});
});
// Animate console on initial load
const activeConsole = document.querySelector('.tab-content.active .console-output');
if (activeConsole) {
const consoleLines = activeConsole.querySelectorAll('.console-line');
gsap.fromTo(consoleLines,
{ opacity: 0, x: -20 },
{
opacity: 1,
x: 0,
duration: 0.4,
stagger: 0,
ease: 'power2.out',
delay: 0
}
);
}
// Set initial state for summary section title
gsap.set('.summary .section-title', { opacity: 0, y: 30 });
// Summary section title animation
gsap.to('.summary .section-title', {