fix: use capture:true on touch event listeners to prevent page JS interference
Touch handlers used bubble phase (no capture:true), so any page script that called stopPropagation() on touchstart/touchend — e.g. Authelia's login form or scroll containers — silently blocked the preload's swipe detection. Using capture:true fires the preload's listeners in the capture phase (before any element-level handlers), so swipe works even on pages with their own touch handling. Applied to both preloads (standard and auto-show keyboard). Also adds missing [TOUCH] 2-finger HORIZONTAL console.log to the standard preload so swipe events are visible in electron.log for debugging. https://claude.ai/code/session_01EyjEQLWbTXcZgbMDarf7NU
This commit is contained in:
@@ -7172,8 +7172,8 @@ window.addEventListener('DOMContentLoaded',()=>{
|
||||
touchStartTime=Date.now();
|
||||
fingerCount=e.touches.length;
|
||||
}
|
||||
},{passive:true});
|
||||
|
||||
},{passive:true,capture:true});
|
||||
|
||||
document.addEventListener('touchend',e=>{
|
||||
if(e.changedTouches.length>=1){
|
||||
const touchEndX=e.changedTouches[0].clientX;
|
||||
@@ -7181,9 +7181,9 @@ window.addEventListener('DOMContentLoaded',()=>{
|
||||
const deltaX=touchEndX-touchStartX;
|
||||
const deltaY=touchEndY-touchStartY;
|
||||
const deltaTime=Date.now()-touchStartTime;
|
||||
|
||||
|
||||
if(deltaTime>SWIPE_MAX_TIME)return;
|
||||
|
||||
|
||||
const absX=Math.abs(deltaX);
|
||||
const absY=Math.abs(deltaY);
|
||||
|
||||
@@ -7194,6 +7194,7 @@ window.addEventListener('DOMContentLoaded',()=>{
|
||||
}
|
||||
// 2-finger HORIZONTAL = change tabs
|
||||
else if(fingerCount===2&&absX>SWIPE_THRESHOLD&&absY<SWIPE_TOLERANCE){
|
||||
console.log('[TOUCH] 2-finger HORIZONTAL - change tab');
|
||||
ipcRenderer.send(deltaX>0?'swipe-right':'swipe-left');
|
||||
}
|
||||
// 1-finger HORIZONTAL = arrow keys
|
||||
@@ -7207,7 +7208,7 @@ window.addEventListener('DOMContentLoaded',()=>{
|
||||
});
|
||||
}
|
||||
}
|
||||
},{passive:true});
|
||||
},{passive:true,capture:true});
|
||||
|
||||
// Show pause button on user interaction (for rotation sites only)
|
||||
let lastUserInteraction=0;
|
||||
@@ -9188,8 +9189,8 @@ window.addEventListener('DOMContentLoaded',()=>{
|
||||
touchStartTime=Date.now();
|
||||
fingerCount=e.touches.length;
|
||||
}
|
||||
},{passive:true});
|
||||
|
||||
},{passive:true,capture:true});
|
||||
|
||||
document.addEventListener('touchend',e=>{
|
||||
if(e.changedTouches.length>=1){
|
||||
const touchEndX=e.changedTouches[0].clientX;
|
||||
@@ -9197,9 +9198,9 @@ window.addEventListener('DOMContentLoaded',()=>{
|
||||
const deltaX=touchEndX-touchStartX;
|
||||
const deltaY=touchEndY-touchStartY;
|
||||
const deltaTime=Date.now()-touchStartTime;
|
||||
|
||||
|
||||
if(deltaTime>SWIPE_MAX_TIME)return;
|
||||
|
||||
|
||||
const absX=Math.abs(deltaX);
|
||||
const absY=Math.abs(deltaY);
|
||||
|
||||
@@ -9231,7 +9232,7 @@ window.addEventListener('DOMContentLoaded',()=>{
|
||||
});
|
||||
}
|
||||
}
|
||||
},{passive:true});
|
||||
},{passive:true,capture:true});
|
||||
|
||||
// Optional: Auto-show on text field focus (can be disabled)
|
||||
let autoShowEnabled = true; // Set to false to disable auto-show
|
||||
|
||||
Reference in New Issue
Block a user