-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
146 lines (120 loc) · 4.25 KB
/
script.js
File metadata and controls
146 lines (120 loc) · 4.25 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
// Menu Dropdown
const toggleBtn = document.querySelector('.toggle-menu-btn');
const toggleBtnIcon = document.querySelector('.toggle-menu-btn i');
const dropDownMenu = document.querySelector('.dropdown-menu');
const menuItems = document.querySelectorAll('.dropdown-menu a');
toggleBtn.onclick = function () {
dropDownMenu.classList.toggle('open');
const isOpen = dropDownMenu.classList.contains('open');
toggleBtnIcon.classList = isOpen ? 'fa-solid fa-xmark' : 'fa-solid fa-bars';
};
menuItems.forEach(function (menuItem) {
menuItem.addEventListener('click', function () {
// Tutup dropdown saat item menu diklik
dropDownMenu.classList.remove('open');
toggleBtnIcon.classList = 'fa-solid fa-bars';
});
});
// Swiper
var swiper = new Swiper(".swiper", {
effect: 'coverflow',
slidesPerView: 'auto',
slidesPerGroup: 1,
spaceBetween: 25,
centeredSlides: true,
grabCursor: true,
fade: true,
coverflowEffect: {
rotate: 50,
stretch: 0,
depth: 100,
modifier: 1,
slideShadows:true,
},
pagination: {
el: ".swiper-pagination",
clickable: true,
dynamicBullets: true,
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});
// Reveal Animasi
let barAnimated = false;
let countAnimated = false;
window.addEventListener('scroll', reveal);
function reveal(){
var reveals = document.querySelectorAll('.reveal')
for (let i = 0; i < reveals.length; i++) {
let windowHeight = window.innerHeight;
let revealTop = reveals[i].getBoundingClientRect().top;
let revealPoint = 150;
if (revealTop < windowHeight - revealPoint) {
reveals[i].classList.add('active')
if (!countAnimated) {
animateCount('.hitung1 span', 500, 3000);
animateCount('.hitung2 span', 21.33, 3000);
animateCount('.hitung3 span', 40, 3000);
animateCount('.hitung4 span', 144, 3000);
animateCount('.hitung5 span', 50, 3000);
countAnimated = true;
}
if(!barAnimated) {
animateBars();
barAnimated = true;
}
}
else {
reveals[i].classList.remove('active')
}
}
}
// Animasi Bar
function animateBars() {
const bar1 = document.querySelector('.ctn2-grafik-bar1');
const bar2 = document.querySelector('.ctn2-grafik-bar2');
bar1.classList.add('animasi-grafik-bar1')
bar2.classList.add('animasi-grafik-bar2')
}
// Animasi Hitung
function animateCount(element, targetNumber, duration) {
const countElement = document.querySelector(element);
const framesPerSecond = 30;
const increment = targetNumber / (duration / 1000 * framesPerSecond);
let currentNumber = 0;
function updateCount() {
countElement.textContent = Math.round(currentNumber);
currentNumber += increment;
if (currentNumber <= targetNumber) {
requestAnimationFrame(updateCount);
} else {
countElement.textContent = targetNumber;
}
}
updateCount();
}
// Ambil elemen tombol panah
var arrowBtn = document.querySelector('.arrow-display');
// Tambahkan event listener untuk mendeteksi perubahan scroll
window.addEventListener('scroll', function() {
// Ambil posisi scroll vertikal
var scrollPosition = window.scrollY;
// Tentukan posisi elemen target (misalnya, elemen navigasi)
var targetElement = document.querySelector('.ctn1-item-deskripsi');
var targetElementPosition = targetElement.offsetTop;
// Jika posisi scroll melebihi atau sama dengan posisi elemen target, munculkan tombol panah
if (scrollPosition >= targetElementPosition) {
arrowBtn.style.display = 'block';
arrowBtn.classList.add('BounceIn')
} else {
// Jika tidak, sembunyikan tombol panah
arrowBtn.style.display = 'none';
arrowBtn.classList.remove('BounceIn')
}
});
function animateArrow() {
let arrowBtn = document.querySelector('.arrow-display')
arrowBtn.classList.add('arrow-animation')
}