Skip to content

Commit

Permalink
Skip rerenders for mousemove handlers when in selection modes
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer committed Feb 14, 2020
1 parent c7ff98d commit e3edcc2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/lib/mode_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ const ModeHandler = function(mode, DrawContext) {
while (iHandle--) {
const handle = handles[iHandle];
if (handle.selector(event)) {
handle.fn.call(ctx, event);
DrawContext.store.render();
const skipRender = handle.fn.call(ctx, event);
if (!skipRender) {
DrawContext.store.render();
}
DrawContext.ui.updateMapClasses();

// ensure an event is only handled once
Expand Down
6 changes: 6 additions & 0 deletions src/modes/direct_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,17 @@ DirectSelect.onMouseMove = function(state, e) {
else if (onVertex && !noCoords) this.updateUIClasses({ mouse: Constants.cursors.MOVE });
else this.updateUIClasses({ mouse: Constants.cursors.NONE });
this.stopDragging(state);

// Skip render
return true;
};

DirectSelect.onMouseOut = function(state) {
// As soon as you mouse leaves the canvas, update the feature
if (state.dragMoving) this.fireUpdate();

// Skip render
return true;
};

DirectSelect.onTouchStart = DirectSelect.onMouseDown = function(state, e) {
Expand Down
4 changes: 1 addition & 3 deletions src/modes/object_to_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ export default function(modeObject) {
}, new ModeInterface(ctx));

function wrapper(eh) {
return function(e) {
mode[eh](state, e);
};
return e => mode[eh](state, e);
}

return {
Expand Down
8 changes: 7 additions & 1 deletion src/modes/simple_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,18 @@ SimpleSelect.onMouseMove = function(state) {
// then move the mouse back over the canvas --- we don't allow the
// interaction to continue then, but we do let it continue if you held
// the mouse button that whole time
return this.stopExtendedInteractions(state);
this.stopExtendedInteractions(state);

// Skip render
return true;
};

SimpleSelect.onMouseOut = function(state) {
// As soon as you mouse leaves the canvas, update the feature
if (state.dragMoving) return this.fireUpdate();

// Skip render
return true;
};

SimpleSelect.onTap = SimpleSelect.onClick = function(state, e) {
Expand Down

0 comments on commit e3edcc2

Please sign in to comment.