Skip to content

Commit

Permalink
Update stars.js
Browse files Browse the repository at this point in the history
修复了网页滚动后星星生成与鼠标位置偏移量越来越大的bug
  • Loading branch information
Carlyuanss authored May 27, 2024
1 parent 90e84ac commit 8a2a268
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/stars.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
// 处理鼠标移动事件,为鼠标位置创建星星
function handleMouseMove(event) {
var rect = document.body.getBoundingClientRect();
var mouseX = event.clientX - rect.left;
var mouseY = event.clientY - rect.top;
var mouseX = event.clientX - rect.left - window.scrollX;
var mouseY = event.clientY - rect.top - window.scrollY;
for (var i = 0; i < 1; i++) {
createStar(mouseX, mouseY, getRandomColor());
}
Expand Down

0 comments on commit 8a2a268

Please sign in to comment.