diff options
author | Dante Catalfamo | 2025-01-08 21:22:24 -0500 |
---|---|---|
committer | Dante Catalfamo | 2025-01-08 21:22:24 -0500 |
commit | 4fbf4bca5e66bd7b7dc5b0dbac337351d3d47bfa (patch) | |
tree | e00ae6252fe626178fb7aa3b5e516b16a61d84ca /public | |
parent | 66292c0e95236a024f61439465d8992ebfb49b1f (diff) | |
download | homepage-4fbf4bca5e66bd7b7dc5b0dbac337351d3d47bfa.tar.gz homepage-4fbf4bca5e66bd7b7dc5b0dbac337351d3d47bfa.tar.bz2 homepage-4fbf4bca5e66bd7b7dc5b0dbac337351d3d47bfa.zip |
Reverse text when mouse moves backwards
Diffstat (limited to 'public')
-rw-r--r-- | public/trail.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/public/trail.js b/public/trail.js index 6cafc7d..97b6d3d 100644 --- a/public/trail.js +++ b/public/trail.js @@ -39,16 +39,19 @@ window.addEventListener("mousemove", (event) => { } lastY = y; lastX = x; - placeText(x+"px",y+"px", "e"); + placeText(x+"px",y+"px", x < lastX); }); -function placeText(x, y) { +function placeText(x, y, reversed) { const char = mouseText[curChar++ % mouseText.length]; const el = document.createElement("div"); el.className = "chr"; el.style.left = x; el.style.top = y; el.innerText = char; + if (reversed) { + el.style.transform = "scaleX(-1)"; + } window.setTimeout(() => { el.remove(); }, 2000); |