-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
74 lines (57 loc) · 2.22 KB
/
script.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
// Color Scheme Selection
document.getElementById('color-scheme1').addEventListener('click', function() {
document.body.style.backgroundColor = '#ffffff';
});
document.getElementById('color-scheme2').addEventListener('click', function() {
document.body.style.backgroundColor = ' #545454';
});
document.getElementById('color-scheme3').addEventListener('click', function() {
document.body.style.backgroundColor = '#c6e1c6';
});
// Random Color Scheme
document.getElementById('random-color-scheme').addEventListener('click', function() {
var randomColor = '#' + Math.floor(Math.random() * 16777215).toString(16);
document.body.style.backgroundColor = randomColor;
});
// Font Size Control
var fontSize = 16; // Initial font size in pixels
document.getElementById('increase-font').addEventListener('click', function() {
fontSize += 0.5;
document.body.style.fontSize = fontSize + 'px';
});
document.getElementById('decrease-font').addEventListener('click', function() {
fontSize -= 0.5;
document.body.style.fontSize = fontSize + 'px';
});
function moveClouds(callback) {
/* clouds 1 & 2 move to the left
clouds 3 & 4 to the right */
for (var i = 1; i < 5; i++) {
var cloud = document.getElementById("cloud" + i);
cloud.style.transitionTimingFunction = "ease-out";
cloud.style.transitionDuration = "10ms";
var top = window.getComputedStyle(cloud, null).getPropertyValue("top");
var topValue = parseInt(top);
topValue = topValue - 20;
top = topValue + "px";
cloud.style.top = top;
var left = window.getComputedStyle(cloud, null).getPropertyValue("left");
var leftValue = parseInt(left);
if (i < 3) {
leftValue = leftValue - 30;
} else {
leftValue = leftValue + 30;
}
left = leftValue + "px";
cloud.style.left = left;
}
// Delay the execution of the callback function after the transition completes
setTimeout(callback, 10);
}
// Example usage:
moveClouds(function() {
// Code to execute after all clouds have disappeared
var textElement = document.getElementById("mainText");
textElement.innerText = "Welcome";
});
//JS part got from - https://codepen.io/trixie13/pen/GNJqBJ