Skip to content

Commit 6169573

Browse files
authored
Merge pull request #26 from iskepr/main
اضافة الاضاءة خلف المؤشر و تعديل ساعة العداد
2 parents 4c8fbd1 + 5b30a97 commit 6169573

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

Source/JavaScript/script.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,55 @@ function notify(text) {
7575
}, 500);
7676
}, 3000);
7777
}
78+
79+
80+
let cursor = document.createElement("div");
81+
cursor.setAttribute("id", "cursor");
82+
cursor.style = `
83+
position: fixed;
84+
border-radius: 100%;
85+
box-shadow: 0 0 200px 80px #2079ff90;`;
86+
document.body.appendChild(cursor);
87+
88+
const mouse = { x: 0, y: 0 };
89+
const previousMouse = { x: 0, y: 0 };
90+
const circle = { x: 0, y: 0 };
91+
let currentScale = 0;
92+
93+
window.addEventListener("mousemove", (e) => {
94+
mouse.x = e.x;
95+
mouse.y = e.y;
96+
});
97+
98+
const speed = 0.17;
99+
100+
const tick = () => {
101+
// position
102+
circle.x += (mouse.x - circle.x) * speed;
103+
circle.y += (mouse.y - circle.y) * speed;
104+
const position = `translate(${circle.x}px, ${circle.y}px)`;
105+
106+
const deltaMouseX = mouse.x - previousMouse.x;
107+
const deltaMouseY = mouse.y - previousMouse.y;
108+
109+
// scale
110+
previousMouse.x = mouse.x;
111+
previousMouse.y = mouse.y;
112+
const mouseVelocity = Math.min(
113+
Math.sqrt(deltaMouseX ** 2 + deltaMouseY ** 2) * 10,
114+
150
115+
);
116+
const scaleValue = (mouseVelocity / 150) * 0.5;
117+
currentScale += (scaleValue - currentScale) * speed;
118+
const scale = `scaleX(${1 + currentScale}) scaleY(${1.5 - currentScale})`;
119+
120+
// rotate
121+
const angle = (Math.atan2(deltaMouseY, deltaMouseX) * 180) / Math.PI;
122+
const rotate = `rotate(${angle}deg)`;
123+
124+
cursor.style.transform = position + rotate + scale;
125+
126+
window.requestAnimationFrame(tick);
127+
};
128+
129+
tick();

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135

136136
<script>
137137
function updateCountdown() {
138-
const newYear = new Date("2025-06-26");
138+
const newYear = new Date("2025-06-26T04:00:00+02:00");
139139
const now = new Date();
140140
const timeDifference = newYear - now;
141141

0 commit comments

Comments
 (0)