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,7 +7172,7 @@ window.addEventListener('DOMContentLoaded',()=>{
|
|||||||
touchStartTime=Date.now();
|
touchStartTime=Date.now();
|
||||||
fingerCount=e.touches.length;
|
fingerCount=e.touches.length;
|
||||||
}
|
}
|
||||||
},{passive:true});
|
},{passive:true,capture:true});
|
||||||
|
|
||||||
document.addEventListener('touchend',e=>{
|
document.addEventListener('touchend',e=>{
|
||||||
if(e.changedTouches.length>=1){
|
if(e.changedTouches.length>=1){
|
||||||
@@ -7194,6 +7194,7 @@ window.addEventListener('DOMContentLoaded',()=>{
|
|||||||
}
|
}
|
||||||
// 2-finger HORIZONTAL = change tabs
|
// 2-finger HORIZONTAL = change tabs
|
||||||
else if(fingerCount===2&&absX>SWIPE_THRESHOLD&&absY<SWIPE_TOLERANCE){
|
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');
|
ipcRenderer.send(deltaX>0?'swipe-right':'swipe-left');
|
||||||
}
|
}
|
||||||
// 1-finger HORIZONTAL = arrow keys
|
// 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)
|
// Show pause button on user interaction (for rotation sites only)
|
||||||
let lastUserInteraction=0;
|
let lastUserInteraction=0;
|
||||||
@@ -9188,7 +9189,7 @@ window.addEventListener('DOMContentLoaded',()=>{
|
|||||||
touchStartTime=Date.now();
|
touchStartTime=Date.now();
|
||||||
fingerCount=e.touches.length;
|
fingerCount=e.touches.length;
|
||||||
}
|
}
|
||||||
},{passive:true});
|
},{passive:true,capture:true});
|
||||||
|
|
||||||
document.addEventListener('touchend',e=>{
|
document.addEventListener('touchend',e=>{
|
||||||
if(e.changedTouches.length>=1){
|
if(e.changedTouches.length>=1){
|
||||||
@@ -9231,7 +9232,7 @@ window.addEventListener('DOMContentLoaded',()=>{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},{passive:true});
|
},{passive:true,capture:true});
|
||||||
|
|
||||||
// Optional: Auto-show on text field focus (can be disabled)
|
// Optional: Auto-show on text field focus (can be disabled)
|
||||||
let autoShowEnabled = true; // Set to false to disable auto-show
|
let autoShowEnabled = true; // Set to false to disable auto-show
|
||||||
|
|||||||
Reference in New Issue
Block a user