summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-01-04 23:25:07 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-01-04 23:25:07 +0800
commit3db257dab76e588fb8477affbbe3c749cb916fff (patch)
treec3c83a87f8e61c76ef6477037756aa3b37540665 /src
parent279207882015c35d79f7fe6c96cc969fe9156bf1 (diff)
added comments
Diffstat (limited to 'src')
-rw-r--r--src/js/mouseblob.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/js/mouseblob.js b/src/js/mouseblob.js
index 019a2ffa..db755edd 100644
--- a/src/js/mouseblob.js
+++ b/src/js/mouseblob.js
@@ -28,23 +28,27 @@
// }
window.onpointermove = event => {
- // The event object gives us the x and y coordinates of the mouse pointer
const { pageX, pageY } = event;
+ // Get Initial Momentum
const momentumX = pageX + pageX - blob.offsetLeft;
const momentumY = pageY + pageY - blob.offsetTop;
+ // Move to momentem offseted position
+
blob.animate({
left: `${momentumX}px`,
top: `${momentumY}px`
}, { duration: 1500, fill: "forwards" });
+
+ // Move/Bounce back to initial mouse after momentum
blob.animate({
left: `${pageX}px`,
top: `${pageY}px`
}, { duration: 1000, fill: "forwards" });
- // We can then use these coordinates to position the blob
+ // Set Default Initial position for blob / fix safari as the animate don't presist(it don't care about fill forwards)
blob.style.left = `${pageX}px`;
blob.style.top = `${pageY}px`;
}