Last active
August 28, 2025 18:35
-
-
Save greggman/279bf9a730b8829cf4717f74a914126a to your computer and use it in GitHub Desktop.
pointerdown/move/up test
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 characters
:root { | |
color-scheme: light dark; | |
} | |
html { | |
overscroll-behavior: none; | |
touch-action: none; | |
} |
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 characters
<p>drag mouse/finger</p> | |
<pre id="log"></pre> |
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 characters
const lines = []; | |
const logElem = document.querySelector('#log'); | |
function log(msg) { | |
lines.push(msg); | |
lines.splice(0, lines.length - 20); | |
logElem.textContent = lines.join('\n'); | |
} | |
function onMove(e) { | |
e.preventDefault(); | |
log('pointermove'); | |
log(`${e.clientX}, ${e.clientY}`); | |
} | |
function onUp(e) { | |
e.preventDefault(); | |
log('pointerup'); | |
window.removeEventListener('pointerup', onUp); | |
window.removeEventListener('pointermove', onMove); | |
} | |
function onDown(e) { | |
log('pointerdown'); | |
onMove(e); | |
window.addEventListener('pointerup', onUp, { passive: false }); | |
window.addEventListener('pointermove', onMove, { passive: false }); | |
} | |
function preventScroll(e) { | |
e.preventDefault(); | |
} | |
//window.addEventListener('touchmove', preventScroll, { passive: false }); | |
window.addEventListener('pointerdown', onDown, { passive: false }); | |
log('start'); |
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 characters
{"name":"pointerdown/move/up test","settings":{},"filenames":["index.html","index.css","index.js"]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment