-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage2.js
More file actions
114 lines (96 loc) · 3.45 KB
/
page2.js
File metadata and controls
114 lines (96 loc) · 3.45 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
function createHearts() {
const heartsContainer = document.getElementById("hearts");
const numHearts = 15;
for (let i = 0; i < numHearts; i++) {
const heart = document.createElement("div");
heart.className = "heart";
heart.innerHTML = "💖";
heart.style.left = Math.random() * 100 + "%";
heart.style.top = Math.random() * 100 + "%";
heart.style.animationDelay = Math.random() * 3 + "s";
heartsContainer.appendChild(heart);
}
}
function createConstellation() {
const numStars = 30;
for (let i = 0; i < numStars; i++) {
const star = document.createElement("div");
star.className = "constellation";
star.style.left = Math.random() * 100 + "%";
star.style.top = Math.random() * 100 + "%";
star.style.animationDelay = Math.random() * 2 + "s";
document.body.appendChild(star);
}
}
function addColoredSparkleEffect() {
document.addEventListener("click", function (e) {
if (e.target.classList.contains("nav-button")) return;
const colors = ["#ff6b6b", "#4ecdc4", "#45b7d1", "#f9ca24", "#f0932b"];
const sparkle = document.createElement("div");
sparkle.style.position = "fixed";
sparkle.style.left = e.clientX + "px";
sparkle.style.top = e.clientY + "px";
sparkle.style.width = "20px";
sparkle.style.height = "20px";
sparkle.style.background =
colors[Math.floor(Math.random() * colors.length)];
sparkle.style.clipPath =
"polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%)";
sparkle.style.pointerEvents = "none";
sparkle.style.zIndex = "1000";
sparkle.style.animation = "sparkle-burst 0.8s ease-out forwards";
document.body.appendChild(sparkle);
setTimeout(() => {
sparkle.remove();
}, 800);
});
}
function showCodeModal() {
const modal = document.getElementById('codeModal');
modal.showModal();
modal.addEventListener('click', function(e) {
if (e.target === modal) {
modal.close();
}
});
}
function copyCSS() {
const cssCode = `@view-transition {
navigation: auto;
}
/* Star Wipe Animations */
::view-transition-old(root) {
animation: star-wipe-out 0.9s ease-in-out;
}
::view-transition-new(root) {
animation: star-wipe-in 0.9s ease-in-out;
}
@keyframes star-wipe-out {
/* Required to keep old page visible during transition */
}
@keyframes star-wipe-in {
from {
clip-path: polygon(50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%);
}
to {
clip-path: polygon(calc(50vmin + 50vw - 50vmin) -300vmin, calc(188vmin + 50vw - 50vmin) -24vmin, calc(484vmin + 50vw - 50vmin) -24vmin, calc(244vmin + 50vw - 50vmin) 152vmin, calc(332vmin + 50vw - 50vmin) 424vmin, calc(50vmin + 50vw - 50vmin) 256vmin, calc(-232vmin + 50vw - 50vmin) 424vmin, calc(-144vmin + 50vw - 50vmin) 152vmin, calc(-384vmin + 50vw - 50vmin) -24vmin, calc(-88vmin + 50vw - 50vmin) -24vmin);
}
}`;
navigator.clipboard.writeText(cssCode).then(function() {
const button = document.querySelector('.copy-button');
button.textContent = 'Copied!';
button.classList.add('copied');
setTimeout(function() {
button.textContent = 'Copy CSS';
button.classList.remove('copied');
}, 2000);
}).catch(function(err) {
console.error('Failed to copy: ', err);
});
}
document.addEventListener("DOMContentLoaded", function () {
createHearts();
createConstellation();
addColoredSparkleEffect();
showBrowserNotice();
});