From ad4435057968dd9111def87ca1ef1b4dd2f43504 Mon Sep 17 00:00:00 2001 From: Honza Date: Tue, 14 Mar 2023 14:24:15 +0100 Subject: [PATCH] Fix inconsistent `draw.update` fires (#1160) (h/t @gynekolog) --- src/modes/direct_select.js | 5 +++++ src/modes/simple_select.js | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modes/direct_select.js b/src/modes/direct_select.js index 7ba82e9d5..83f41c958 100644 --- a/src/modes/direct_select.js +++ b/src/modes/direct_select.js @@ -183,10 +183,15 @@ DirectSelect.onMouseMove = function(state, e) { // On mousemove that is not a drag, stop vertex movement. const isFeature = isActiveFeature(e); const onVertex = isVertex(e); + const isMidPoint = isMidpoint(e); const noCoords = state.selectedCoordPaths.length === 0; if (isFeature && noCoords) this.updateUIClasses({ mouse: Constants.cursors.MOVE }); else if (onVertex && !noCoords) this.updateUIClasses({ mouse: Constants.cursors.MOVE }); else this.updateUIClasses({ mouse: Constants.cursors.NONE }); + + const isDraggableItem = onVertex || isFeature || isMidPoint; + if (isDraggableItem && state.dragMoving) this.fireUpdate(); + this.stopDragging(state); // Skip render diff --git a/src/modes/simple_select.js b/src/modes/simple_select.js index b8550db53..4802d18b1 100644 --- a/src/modes/simple_select.js +++ b/src/modes/simple_select.js @@ -97,7 +97,10 @@ SimpleSelect.onStop = function() { doubleClickZoom.enable(this); }; -SimpleSelect.onMouseMove = function(state) { +SimpleSelect.onMouseMove = function(state, e) { + const isFeature = CommonSelectors.isFeature(e); + if (isFeature && state.dragMoving) this.fireUpdate(); + // On mousemove that is not a drag, stop extended interactions. // This is useful if you drag off the canvas, release the button, // then move the mouse back over the canvas --- we don't allow the