I'm working on a web app which needs to prevent scrolling on using a stylus but still allow scrolling on swiping the screen with a finger.
The problem I'm running into is that only the pointerstart event can distinguish between a finger touch and stylus pen touch via e.pointerType.
But it seems that it is impossible to stop the scrolling from pointerdown and needs to use touchstart which cannot detect the different between fingers and stylus/pen.
On Google Keep this is achieved by setting css touch-events:none; on the canvas and using pointer events to generate a simulated panning if it is a finger touch but that seems hacky.
Sample code I want to achieve
canvasElement.addEventlistener("pointerdown", function(event){
if(event.pointerType === "pen"){
// Disable scroll - This doesn't work
event.preventDefault();
event.stopPropagation();
// Start drawing stuff
startDrawing(...);
} else {
// Is a touch event do nothing, let it scroll naturally
}
});
Any way this is possible without simulating a scroll?