-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
77 lines (64 loc) · 2.41 KB
/
script.js
File metadata and controls
77 lines (64 loc) · 2.41 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
document.addEventListener('DOMContentLoaded', () => {
// DOM element selections
const skateboarder = document.getElementById('skateboarder');
const imageUpload = document.getElementById('imageUpload');
const title = document.querySelector('h1');
const mainContainer = document.querySelector('.container');
const cvContainer = document.getElementById('cv-container');
const backButton = document.querySelector('.back-button');
const flipButton = document.getElementById('flipButton');
// State variables
let clickCount = 0;
let clickTimer;
// Image upload handler
imageUpload.addEventListener('change', function(e) {
const file = e.target.files[0];
const reader = new FileReader();
reader.onload = function(e) {
skateboarder.style.backgroundImage = `url('${e.target.result}')`;
};
reader.readAsDataURL(file);
});
// Flip button handler
flipButton.addEventListener('click', startAnimation);
function startAnimation() {
// Make image fully transparent
skateboarder.classList.add('transparent');
// Move image to screen side
setTimeout(() => {
skateboarder.classList.add('start-position');
}, 500);
// Gradually reappear before flip
setTimeout(() => {
skateboarder.classList.remove('transparent');
skateboarder.classList.add('fade-in');
}, 1500);
// Add flip animation
setTimeout(() => {
skateboarder.classList.add('animate');
}, 2000);
}
// Animation end handler
skateboarder.addEventListener('animationend', () => {
// Reset all classes
skateboarder.classList.remove('start-position', 'animate', 'transparent', 'fade-in');
});
// Title click handler for CV toggle
title.addEventListener('click', () => {
clickCount++;
clearTimeout(clickTimer);
clickTimer = setTimeout(() => {
if (clickCount >= 5) {
// Toggle CV view
mainContainer.style.display = 'none';
cvContainer.style.display = 'block';
}
clickCount = 0;
}, 1000);
});
// Back button handler
backButton.addEventListener('click', () => {
mainContainer.style.display = 'block';
cvContainer.style.display = 'none';
});
});