From 8c6d7ea7cc3a1d3e73a1d7a33a4af77d72eb0476 Mon Sep 17 00:00:00 2001 From: Matthew Bloch Date: Fri, 1 Mar 2024 09:48:46 -0500 Subject: [PATCH] Add center handle to draggable box --- src/gui/gui-highlight-box.mjs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/gui-highlight-box.mjs b/src/gui/gui-highlight-box.mjs index 8d6e38cd..80cdd190 100644 --- a/src/gui/gui-highlight-box.mjs +++ b/src/gui/gui-highlight-box.mjs @@ -60,14 +60,17 @@ export function HighlightBox(gui, optsArg) { var scale = gui.map.getExtent().getPixelSize(); var dx = (xy.x - prevXY.x) * scale; var dy = -(xy.y - prevXY.y) * scale; - if (activeHandle.col == 'left') { + var center = activeHandle.col == 'center' && activeHandle.row == 'center'; + if (activeHandle.col == 'left' || center) { boxCoords[0] += dx; - } else if (activeHandle.col == 'right') { + } + if (activeHandle.col == 'right' || center) { boxCoords[2] += dx; } - if (activeHandle.row == 'top') { + if (activeHandle.row == 'top' || center) { boxCoords[3] += dy; - } else if (activeHandle.row == 'bottom') { + } + if (activeHandle.row == 'bottom' || center) { boxCoords[1] += dy; } prevXY = xy; @@ -178,7 +181,7 @@ function fixBounds(bbox) { function initHandles(el) { var handles = []; for (var i=0; i<9; i++) { - if (i == 4) continue; + // if (i == 4) continue; // skip middle handle var c = Math.floor(i / 3); var r = i % 3; handles.push({