-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
29 lines (29 loc) · 1022 Bytes
/
main.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
AOS.init();
document.addEventListener('DOMContentLoaded', function() {
const text = "Al Gozali";
const textElement = document.getElementById('text-ketik');
const cursorElement = document.getElementById('cursor');
let index = 0;
function type() {
if (index < text.length) {
textElement.textContent += text.charAt(index);
index++;
setTimeout(type, 150);
} else {
cursorElement.style.display = 'none';
}
moveCursor();
}
function moveCursor() {
const textLength = textElement.textContent.length;
const textWidth = textElement.offsetWidth;
const fontSize = parseInt(window.getComputedStyle(textElement).fontSize);
const letterSpacing = parseFloat(window.getComputedStyle(textElement).letterSpacing);
const cursorPositionX = (textWidth + letterSpacing) / textLength * index;
cursorElement.style.left = cursorPositionX + 'px';
}
type();
});
document.querySelector('.klik').addEventListener('click', function(){
window.open('https://wa.me/6283139792956?text= the last kid is cute / anak terakhir itu lucu😁😁', '_blank');
});