diff options
author | Ryan Schanzenbacher <ryan@rschanz.org> | 2022-12-05 16:15:37 -0500 |
---|---|---|
committer | Ryan Schanzenbacher <ryan@rschanz.org> | 2022-12-05 16:15:37 -0500 |
commit | 06fcaba51eca0812457d30f2605882e6551ac217 (patch) | |
tree | 39a9a699c04cdf0d2a441c420fc7f202583883f3 | |
parent | 373ad68600de9d1a438d7ef7ea2a999a95dfbaeb (diff) |
chatgpt fixed bug
-rw-r--r-- | index.html | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -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(); |