Skip to content

Commit 28e7d10

Browse files
author
kirbIndustries
authored
Update index.js
1 parent 7c26785 commit 28e7d10

1 file changed

Lines changed: 36 additions & 6 deletions

File tree

js/index.js

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14055,45 +14055,68 @@ function setupDrawerInteractions() {
1405514055
}
1405614056
}, { passive: false });
1405714057

14058+
// Helper to pass click coordinates exactly into the active iframe or system element
1405814059
function forwardClickThroughHandle(x, y) {
1405914060
const drawerHandle = document.querySelector('.drawer-handle');
1406014061
const appDrawerHandle = document.querySelector('.app-drawer-handle');
14061-
const swipeOverlay = document.getElementById('swipe-overlay'); // Bypass this if it's blocking
14062+
const swipeOverlay = document.getElementById('swipe-overlay');
1406214063

1406314064
// Save original states
1406414065
const origDH = drawerHandle ? drawerHandle.style.pointerEvents : '';
1406514066
const origADH = appDrawerHandle ? appDrawerHandle.style.pointerEvents : '';
1406614067
const origSO = swipeOverlay ? swipeOverlay.style.pointerEvents : '';
1406714068

14068-
// Temporarily disable pointer events to "look" through the UI
14069+
// Temporarily disable pointer events on the handles to "look" through the UI
1406914070
if (drawerHandle) drawerHandle.style.pointerEvents = 'none';
1407014071
if (appDrawerHandle) appDrawerHandle.style.pointerEvents = 'none';
1407114072
if (swipeOverlay) swipeOverlay.style.pointerEvents = 'none';
1407214073

14074+
// FIX: Ensure all embeds and iframes are temporarily "hittable" so elementFromPoint
14075+
// doesn't fall straight through to the body.
14076+
const hitElements = document.querySelectorAll('.fullscreen-embed, iframe, .dock-icon, .bento-item');
14077+
const origPointerEvents = new Map();
14078+
hitElements.forEach(el => {
14079+
origPointerEvents.set(el, el.style.pointerEvents);
14080+
el.style.pointerEvents = 'auto';
14081+
});
14082+
1407314083
const el = document.elementFromPoint(x, y);
1407414084

14075-
// Find the iframe (either direct hit, or inside the wrapper)
14085+
// Find the correct iframe (direct hit, or inside the specific embed wrapper we hit)
1407614086
let targetIframe = null;
1407714087
if (el && el.tagName === 'IFRAME') {
1407814088
targetIframe = el;
14079-
} else if (el && el.querySelector('iframe')) {
14089+
} else if (el && el.classList.contains('fullscreen-embed')) {
1408014090
targetIframe = el.querySelector('iframe');
1408114091
}
1408214092

14083-
// Send the relative coordinates to the iframe
1408414093
if (targetIframe && targetIframe.contentWindow) {
14094+
// Forward to Gurapp
1408514095
const rect = targetIframe.getBoundingClientRect();
1408614096
targetIframe.contentWindow.postMessage({
1408714097
type: 'forward-click',
1408814098
x: x - rect.left,
1408914099
y: y - rect.top
1409014100
}, '*');
14101+
} else if (el) {
14102+
// System Support - Trigger native click on parent DOM elements (Dock, Home UI, etc.)
14103+
const clickEvent = new MouseEvent('click', {
14104+
view: window,
14105+
bubbles: true,
14106+
cancelable: true,
14107+
clientX: x,
14108+
clientY: y
14109+
});
14110+
el.dispatchEvent(clickEvent);
1409114111
}
1409214112

1409314113
// Restore original states instantly
1409414114
if (drawerHandle) drawerHandle.style.pointerEvents = origDH;
1409514115
if (appDrawerHandle) appDrawerHandle.style.pointerEvents = origADH;
1409614116
if (swipeOverlay) swipeOverlay.style.pointerEvents = origSO;
14117+
hitElements.forEach(el => {
14118+
el.style.pointerEvents = origPointerEvents.get(el);
14119+
});
1409714120
}
1409814121

1409914122
document.addEventListener('touchend', (e) => {
@@ -14130,10 +14153,13 @@ function setupDrawerInteractions() {
1413014153
}
1413114154
});
1413214155

14133-
// Mouse Events for regular drawer interaction
14156+
// Mouse Events for regular drawer interaction
1413414157
document.addEventListener('mousedown', (e) => {
1413514158
if (oneButtonNavEnabled) return;
1413614159
if (e.button !== 0) return;
14160+
// Prevent ghost duplicate clicks when using a touchscreen
14161+
if (Date.now() - lastTouchTime < 500) return;
14162+
1413714163
const element = document.elementFromPoint(e.clientX, e.clientY);
1413814164

1413914165
// Check if click is on handle area
@@ -14151,6 +14177,10 @@ function setupDrawerInteractions() {
1415114177

1415214178
document.addEventListener('mouseup', (e) => {
1415314179
if (oneButtonNavEnabled) return;
14180+
// Prevent ghost duplicate clicks when using a touchscreen
14181+
// (Browsers fire mouseup a few milliseconds after touchend)
14182+
if (Date.now() - lastTouchTime < 500) return;
14183+
1415414184
if (isDragging) {
1415514185
let isTap = false;
1415614186
const deltaX = Math.abs(e.clientX - startX);

0 commit comments

Comments
 (0)