Widen the edge-tab tap target, split scroll from reposition #9

Merged
sulthan merged 5 commits from userscript-edge-tab-hitbox into main 2026-07-28 20:36:26 +07:00
Showing only changes of commit 8633ee9804 - Show all commits
+17 -8
View File
@@ -1019,6 +1019,16 @@
fab.style.bottom = "auto";
});
function snapToEdge() {
const w = fab.offsetWidth, h = fab.offsetHeight;
const r = fab.getBoundingClientRect();
const side = r.left + w / 2 < window.innerWidth / 2 ? "left" : "right";
const y = clamp(r.top, FAB_MARGIN, window.innerHeight - h - FAB_MARGIN);
fab.style.transition = "left .2s ease, right .2s ease, top .2s ease";
applyFabPos(fab, side, y);
saveFabPos(side, y / window.innerHeight);
}
fab.addEventListener("pointerup", (e) => {
if (!down) return;
const didDrag = moved, didScroll = scrolling;
@@ -1029,16 +1039,15 @@
}
if (!didDrag) return; // tap — let the click handler toggle the panel
fab.dataset.dragged = "1"; // suppress the click that trails this drag
const w = fab.offsetWidth, h = fab.offsetHeight;
const r = fab.getBoundingClientRect();
const side = r.left + w / 2 < window.innerWidth / 2 ? "left" : "right";
const y = clamp(r.top, FAB_MARGIN, window.innerHeight - h - FAB_MARGIN);
fab.style.transition = "left .2s ease, right .2s ease, top .2s ease";
applyFabPos(fab, side, y);
saveFabPos(side, y / window.innerHeight);
snapToEdge();
});
fab.addEventListener("pointercancel", reset);
fab.addEventListener("pointercancel", () => {
if (!down) return;
const didDrag = moved;
reset();
if (didDrag) snapToEdge(); // OS claimed the gesture mid-drag — don't strand the FAB
});
}
// ============================================================