Spaces:
Running
Running
Update script.js
Browse files
script.js
CHANGED
|
@@ -5,15 +5,15 @@ canvas.width = window.innerWidth;
|
|
| 5 |
canvas.height = window.innerHeight;
|
| 6 |
|
| 7 |
const particles = [];
|
| 8 |
-
for (let i = 0; i <
|
| 9 |
particles.push({
|
| 10 |
x: Math.random() * canvas.width,
|
| 11 |
y: Math.random() * canvas.height,
|
| 12 |
-
radius: Math.random() *
|
| 13 |
-
speedX: Math.random() *
|
| 14 |
-
speedY: Math.random() *
|
| 15 |
-
color: `hsl(${Math.random() * 360}, 100%,
|
| 16 |
-
alpha: Math.random() * 0.
|
| 17 |
});
|
| 18 |
}
|
| 19 |
|
|
@@ -27,7 +27,7 @@ function animateCosmo() {
|
|
| 27 |
ctx.fill();
|
| 28 |
p.x += p.speedX;
|
| 29 |
p.y += p.speedY;
|
| 30 |
-
p.alpha = Math.sin(Date.now() * 0.
|
| 31 |
if (p.x < 0 || p.x > canvas.width) p.speedX *= -1;
|
| 32 |
if (p.y < 0 || p.y > canvas.height) p.speedY *= -1;
|
| 33 |
});
|
|
@@ -44,35 +44,45 @@ if ('ontouchstart' in window) {
|
|
| 44 |
touchStartY = e.touches[0].clientY;
|
| 45 |
});
|
| 46 |
product.addEventListener('touchmove', (e) => {
|
| 47 |
-
const deltaX = (e.touches[0].clientX - touchStartX) /
|
| 48 |
-
const deltaY = (e.touches[0].clientY - touchStartY) /
|
| 49 |
-
product.style.transform = `perspective(
|
| 50 |
});
|
| 51 |
product.addEventListener('touchend', () => {
|
| 52 |
-
product.style.transform = 'perspective(
|
| 53 |
});
|
| 54 |
} else {
|
| 55 |
document.addEventListener('mousemove', (e) => {
|
| 56 |
-
const xAxis = (window.innerWidth / 2 - e.pageX) /
|
| 57 |
-
const yAxis = (window.innerHeight / 2 - e.pageY) /
|
| 58 |
-
product.style.transform = `perspective(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
});
|
| 60 |
}
|
| 61 |
|
| 62 |
// Заказ
|
| 63 |
function orderNow() {
|
| 64 |
-
document.body.style.transition = 'background 0.
|
| 65 |
document.body.style.background = 'radial-gradient(circle, #00ffcc, #ff007a, #000)';
|
|
|
|
|
|
|
| 66 |
setTimeout(() => {
|
| 67 |
document.body.style.background = '#000';
|
| 68 |
-
|
|
|
|
| 69 |
alert('Revolut запущен. Твоя кожа — космос!');
|
| 70 |
}
|
| 71 |
|
| 72 |
// Эффекты подов
|
| 73 |
function podEffect(element) {
|
| 74 |
-
element.style.transform = 'translateY(-
|
| 75 |
-
element.style.boxShadow = '0 0
|
| 76 |
}
|
| 77 |
|
| 78 |
function podReset(element) {
|
|
@@ -82,7 +92,7 @@ function podReset(element) {
|
|
| 82 |
|
| 83 |
function podTouch(element) {
|
| 84 |
element.classList.add('active');
|
| 85 |
-
setTimeout(() => element.classList.remove('active'),
|
| 86 |
}
|
| 87 |
|
| 88 |
// Обновление размеров Canvas при изменении окна
|
|
|
|
| 5 |
canvas.height = window.innerHeight;
|
| 6 |
|
| 7 |
const particles = [];
|
| 8 |
+
for (let i = 0; i < 250; i++) {
|
| 9 |
particles.push({
|
| 10 |
x: Math.random() * canvas.width,
|
| 11 |
y: Math.random() * canvas.height,
|
| 12 |
+
radius: Math.random() * 5 + 1,
|
| 13 |
+
speedX: Math.random() * 1 - 0.5,
|
| 14 |
+
speedY: Math.random() * 1 - 0.5,
|
| 15 |
+
color: `hsl(${Math.random() * 360}, 100%, 85%)`,
|
| 16 |
+
alpha: Math.random() * 0.6 + 0.4
|
| 17 |
});
|
| 18 |
}
|
| 19 |
|
|
|
|
| 27 |
ctx.fill();
|
| 28 |
p.x += p.speedX;
|
| 29 |
p.y += p.speedY;
|
| 30 |
+
p.alpha = Math.sin(Date.now() * 0.002 + p.x) * 0.6 + 0.4;
|
| 31 |
if (p.x < 0 || p.x > canvas.width) p.speedX *= -1;
|
| 32 |
if (p.y < 0 || p.y > canvas.height) p.speedY *= -1;
|
| 33 |
});
|
|
|
|
| 44 |
touchStartY = e.touches[0].clientY;
|
| 45 |
});
|
| 46 |
product.addEventListener('touchmove', (e) => {
|
| 47 |
+
const deltaX = (e.touches[0].clientX - touchStartX) / 8;
|
| 48 |
+
const deltaY = (e.touches[0].clientY - touchStartY) / 8;
|
| 49 |
+
product.style.transform = `perspective(3000px) rotateY(${deltaX}deg) rotateX(${-deltaY}deg)`;
|
| 50 |
});
|
| 51 |
product.addEventListener('touchend', () => {
|
| 52 |
+
product.style.transform = 'perspective(3000px) rotateY(0deg) rotateX(0deg)';
|
| 53 |
});
|
| 54 |
} else {
|
| 55 |
document.addEventListener('mousemove', (e) => {
|
| 56 |
+
const xAxis = (window.innerWidth / 2 - e.pageX) / 8;
|
| 57 |
+
const yAxis = (window.innerHeight / 2 - e.pageY) / 8;
|
| 58 |
+
product.style.transform = `perspective(3000px) rotateY(${xAxis}deg) rotateX(${yAxis}deg)`;
|
| 59 |
+
});
|
| 60 |
+
// Дополнительная анимация при наведении на продукт
|
| 61 |
+
product.addEventListener('mouseenter', () => {
|
| 62 |
+
product.style.filter = 'brightness(1.5)';
|
| 63 |
+
});
|
| 64 |
+
product.addEventListener('mouseleave', () => {
|
| 65 |
+
product.style.filter = 'brightness(1)';
|
| 66 |
});
|
| 67 |
}
|
| 68 |
|
| 69 |
// Заказ
|
| 70 |
function orderNow() {
|
| 71 |
+
document.body.style.transition = 'background 0.8s';
|
| 72 |
document.body.style.background = 'radial-gradient(circle, #00ffcc, #ff007a, #000)';
|
| 73 |
+
const title = document.getElementById('cosmo-title');
|
| 74 |
+
title.style.transform = 'scale(1.2)';
|
| 75 |
setTimeout(() => {
|
| 76 |
document.body.style.background = '#000';
|
| 77 |
+
title.style.transform = 'scale(1)';
|
| 78 |
+
}, 1500);
|
| 79 |
alert('Revolut запущен. Твоя кожа — космос!');
|
| 80 |
}
|
| 81 |
|
| 82 |
// Эффекты подов
|
| 83 |
function podEffect(element) {
|
| 84 |
+
element.style.transform = 'translateY(-40px) scale(1.25) translateZ(40px)';
|
| 85 |
+
element.style.boxShadow = '0 0 60px rgba(0, 255, 204, 1)';
|
| 86 |
}
|
| 87 |
|
| 88 |
function podReset(element) {
|
|
|
|
| 92 |
|
| 93 |
function podTouch(element) {
|
| 94 |
element.classList.add('active');
|
| 95 |
+
setTimeout(() => element.classList.remove('active'), 800);
|
| 96 |
}
|
| 97 |
|
| 98 |
// Обновление размеров Canvas при изменении окна
|