Created
October 26, 2019 03:00
-
-
Save davidcalhoun/d3463419dda99b435bf3c9ca5220a5ed to your computer and use it in GitHub Desktop.
Revisions
-
davidcalhoun created this gist
Oct 26, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ /* Keeps track of x/y "progress" as the user mouses over an image */ imageElement.addEventListener('mousemove', e => { const target = e.target; const rect = target.getBoundingClientRect(); const xProgress = Math.floor(((e.clientX - rect.x) / rect.width) * 100); const yProgress = Math.floor(((e.clientY - rect.y) / rect.height) * 100); /* 0,0 = mouse over top left of image, 100/100 = mouse over bottom right of image */ console.log(xProgress, yProgress); }, false)