Skip to content

Commit 3e10e72

Browse files
committed
Robustify lasso selection
1 parent 1b83acc commit 3e10e72

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ const createScatterplot = ({
211211
const currMousePos = getMousePos();
212212

213213
if (!lassoPrevMousePos) {
214-
lassoPos.push(...getMouseGlPos(currMousePos));
215-
lassoScatterPos.push(...getScatterGlPos(currMousePos));
214+
lassoPos = [...getMouseGlPos(currMousePos)];
215+
lassoScatterPos = [...getScatterGlPos(currMousePos)];
216216
lassoPrevMousePos = currMousePos;
217217
} else {
218218
const d = dist(...currMousePos, ...lassoPrevMousePos);
@@ -227,7 +227,7 @@ const createScatterplot = ({
227227
}
228228
}
229229
};
230-
let lassoExtendDb = withThrottle(lassoExtend, lassoMinDelay, true);
230+
let lassoExtendDb = withThrottle(lassoExtend, lassoMinDelay);
231231

232232
const findPointsInLasso = lassoPolygon => {
233233
// get the bounding box of the lasso selection...
@@ -296,8 +296,12 @@ const createScatterplot = ({
296296
mouseDownPosition = getRelativeMousePosition(event);
297297
mouseDownShift = event.shiftKey;
298298

299-
// fix camera
300-
if (mouseDownShift) camera.config({ isFixed: true });
299+
if (mouseDownShift) {
300+
// Fix camera for the lasso selection
301+
camera.config({ isFixed: true });
302+
// Make sure we start a new lasso selection
303+
lassoPrevMousePos = undefined;
304+
}
301305
};
302306

303307
const mouseUpHandler = () => {
@@ -753,7 +757,7 @@ const createScatterplot = ({
753757
if (!+newLassoMinDelay) return;
754758

755759
lassoMinDelay = +newLassoMinDelay;
756-
lassoExtendDb = withThrottle(lassoExtend, lassoMinDelay, true);
760+
lassoExtendDb = withThrottle(lassoExtend, lassoMinDelay);
757761
};
758762

759763
const setLassoMinDist = newLassoMinDist => {

0 commit comments

Comments
 (0)