From 8373fe2637300fef70bf988ef7b61037d360d70d Mon Sep 17 00:00:00 2001 From: Ruben Carlo Benante Date: Mon, 6 Jul 2026 20:47:01 -0300 Subject: [PATCH] fix autoscroll: mobile drag pageY + cap vertical scroll at board bottom+200px; v1.2.1 --- Asset/js/drag-autoscroll.js | 26 +++++++++++++++++++++++--- Plugin.php | 2 +- VERSION | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Asset/js/drag-autoscroll.js b/Asset/js/drag-autoscroll.js index 55a2376..f184593 100644 --- a/Asset/js/drag-autoscroll.js +++ b/Asset/js/drag-autoscroll.js @@ -28,6 +28,7 @@ var EDGE_ZONE_MAX = 160; // ...and at most 160px. var MAX_SPEED = 22; // px per animation frame at the very edge var EASE = 1; // 1 = linear ramp, 2 = gentle-then-fast + var SCROLL_SAFETY = 200; // px of page we may scroll past the bottom of the columns var jq = window.jQuery; if (!jq) { @@ -116,6 +117,20 @@ vspeed = speedFor(dBottom, zoneV); } + // Cap downward scrolling to just past the bottom of the columns, so a drag held at + // the bottom edge cannot scroll the page forever. #board is the columns table, so + // its height is the tallest column; allow SCROLL_SAFETY px beyond it. + if (vspeed > 0) { + var boardEl = document.getElementById("board"); + if (boardEl) { + var boardBottomPage = boardEl.getBoundingClientRect().bottom + window.pageYOffset; + var maxScrollY = boardBottomPage + SCROLL_SAFETY - window.innerHeight; + if (window.pageYOffset >= maxScrollY) { + vspeed = 0; + } + } + } + if (vspeed !== 0) { var beforeY = window.pageYOffset; window.scrollBy(0, vspeed); @@ -125,12 +140,17 @@ } // When the board/page actually moved, nudge jQuery UI to recompute drop positions - // so the placeholder follows onto the newly revealed area (either axis). + // so the placeholder follows onto the newly revealed area (either axis). Dispatch + // through jQuery with EXPLICIT page coordinates: a raw synthetic MouseEvent does not + // carry a correct pageY on mobile browsers, which made jQuery UI drop the dragged + // card to a wrong vertical position (X right, Y jumping up). if (moved) { - document.dispatchEvent(new MouseEvent("mousemove", { + jq(document).trigger(jq.Event("mousemove", { + which: 1, clientX: lastX, clientY: lastY, - bubbles: true + pageX: lastX + window.pageXOffset, + pageY: lastY + window.pageYOffset })); } diff --git a/Plugin.php b/Plugin.php index 1e997bd..3855339 100644 --- a/Plugin.php +++ b/Plugin.php @@ -50,7 +50,7 @@ class Plugin extends Base public function getPluginVersion() { - return '1.2.0'; + return '1.2.1'; } public function getPluginHomepage() diff --git a/VERSION b/VERSION index 759433d..a96ffce 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -TweakDrag v1.2 +TweakDrag v1.2.1