Skip to content

Commit fe506fc

Browse files
devvaannshabose
authored andcommitted
fix: ignore tiny pointer jitter when starting a resize drag
1 parent 1406d12 commit fe506fc

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎src/utils/Resizer.js‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ define(function (require, exports, module) {
9595
*/
9696
var PREFS_PURE_CODE = "noDistractions";
9797

98+
// to ignore the small jitters that might happen during click
99+
const DRAG_START_THRESHOLD = 3;
100+
98101
/**
99102
* Event triggered when a panel is collapsed.
100103
*
@@ -496,6 +499,7 @@ define(function (require, exports, module) {
496499
previousSize = startSize,
497500
baseSize = 0,
498501
resizeStarted = false;
502+
let dragThresholdCrossed = false;
499503

500504
isResizing = true;
501505
$body.append($resizeShield);
@@ -559,6 +563,15 @@ define(function (require, exports, module) {
559563
}
560564

561565
function onMouseMove(e) {
566+
e.preventDefault();
567+
568+
if (!dragThresholdCrossed) {
569+
if (Math.abs(e[directionProperty] - startPosition) < DRAG_START_THRESHOLD) {
570+
return;
571+
}
572+
dragThresholdCrossed = true;
573+
}
574+
562575
// calculate newSize adding to startSize the difference
563576
// between starting and current position, capped at minSize
564577
newSize = Math.max(startSize + directionIncrement * (startPosition - e[directionProperty]), minSize);
@@ -580,8 +593,6 @@ define(function (require, exports, module) {
580593
}
581594
}
582595

583-
e.preventDefault();
584-
585596
if (animationRequest === null) {
586597
animationRequest = window.requestAnimationFrame(doRedraw);
587598
}

0 commit comments

Comments
 (0)