summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Schanzenbacher <ryan@rschanz.org>2022-12-05 16:15:37 -0500
committerRyan Schanzenbacher <ryan@rschanz.org>2022-12-05 16:15:37 -0500
commit06fcaba51eca0812457d30f2605882e6551ac217 (patch)
tree39a9a699c04cdf0d2a441c420fc7f202583883f3
parent373ad68600de9d1a438d7ef7ea2a999a95dfbaeb (diff)
chatgpt fixed bug
-rw-r--r--index.html22
1 files changed, 15 insertions, 7 deletions
diff --git a/index.html b/index.html
index 949b29e..2eda64d 100644
--- a/index.html
+++ b/index.html
@@ -151,14 +151,22 @@
151 } 151 }
152 } 152 }
153 153
154 var lastX = 0;
155 var lastY = 0;
156
154 function moveTrail(e) { 157 function moveTrail(e) {
155 for (let i = 0; i < path.length; i++) { 158 if (lastX !== e.pageX || lastY !== e.pageY) {
156 setTimeout(function() { 159 for (let i = 0; i < path.length; i++) {
157 path[i].style.top = (e.clientY) + 'px'; 160 setTimeout(function() {
158 path[i].style.left = (e.clientX) + 'px'; 161 path[i].style.top = (e.pageY) + 'px';
159 }, i * delay); 162 path[i].style.left = (e.pageX) + 'px';
160 } 163 }, i * delay);
161} 164 }
165 }
166
167 lastX = e.pageX;
168 lastY = e.pageY;
169 }
162 170
163 document.addEventListener('mousemove', moveTrail); 171 document.addEventListener('mousemove', moveTrail);
164 createMouseTrail(); 172 createMouseTrail();