diff --git a/package.json b/package.json index 29fb6bb13..94ff6718d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "@mapbox/mapbox-gl-draw", - "version": "1.1.1", + "name": "@gisaia-team/mapbox-gl-draw", + "version": "1.1.2", "description": "A drawing component for Mapbox GL JS", "homepage": "https://github.com/mapbox/mapbox-gl-draw", "author": "mapbox", diff --git a/src/events.js b/src/events.js index bd98eaacd..557ee4a3e 100644 --- a/src/events.js +++ b/src/events.js @@ -174,7 +174,7 @@ module.exports = function(ctx) { } currentModeName = modename; const mode = modebuilder(ctx, nextModeOptions); - currentMode = setupModeHandler(mode, ctx); + currentMode = setupModeHandler(mode, currentModeName, ctx); if (!eventOptions.silent) { ctx.map.fire(Constants.events.MODE_CHANGE, { mode: modename}); @@ -203,7 +203,7 @@ module.exports = function(ctx) { const api = { start: function() { currentModeName = ctx.options.defaultMode; - currentMode = setupModeHandler(modes[currentModeName](ctx), ctx); + currentMode = setupModeHandler(modes[currentModeName](ctx), currentModeName, ctx); }, changeMode, actionable, diff --git a/src/lib/mode_handler.js b/src/lib/mode_handler.js index 22c163b16..32e7c8a10 100644 --- a/src/lib/mode_handler.js +++ b/src/lib/mode_handler.js @@ -1,5 +1,5 @@ -const ModeHandler = function(mode, DrawContext) { +const ModeHandler = function(mode, modename, DrawContext) { const handlers = { drag: [], @@ -38,7 +38,7 @@ const ModeHandler = function(mode, DrawContext) { const handle = handles[iHandle]; if (handle.selector(event)) { handle.fn.call(ctx, event); - DrawContext.store.render(); + if (handle.fn.render !== false) DrawContext.store.render(); DrawContext.ui.updateMapClasses(); // ensure an event is only handled once @@ -79,7 +79,9 @@ const ModeHandler = function(mode, DrawContext) { delegate('click', event); }, mousemove: function(event) { - delegate('mousemove', event); + if (modename !== 'simple_select' && modename !== 'direct_select' && modename !== 'limit_vertex') { + delegate('mousemove', event); + } }, mousedown: function(event) { delegate('mousedown', event); diff --git a/test/mode_handler.test.js b/test/mode_handler.test.js index 679a2c09f..815880128 100644 --- a/test/mode_handler.test.js +++ b/test/mode_handler.test.js @@ -39,7 +39,7 @@ test('ModeHandler calling mode.start with context, and delegation functionality' }); const drawContext = createMockModeHandlerContext(); - const mh = modeHandler(mode, drawContext); + const mh = modeHandler(mode, 'mode.start', drawContext); t.equal(handleStartSpy.callCount, 1, 'start was called on mode handler creation'); t.equal(typeof startContext.on, 'function', 'start context has on()'); t.equal(typeof startContext.render, 'function', 'start context has render()'); @@ -137,7 +137,7 @@ test('ModeHandler calling mode.start with context, and delegation functionality' test('ModeHandler#stop calling mode.stop', t => { const mode = createMockMode(); - const mh = modeHandler(mode, createMockModeHandlerContext()); + const mh = modeHandler(mode, 'mode.stop', createMockModeHandlerContext()); mh.stop(); t.equal(mode.stop.callCount, 1, 'mode.stop called'); @@ -148,7 +148,7 @@ test('ModeHandler#stop calling mode.stop', t => { test('ModeHandler#stop not calling nonexistent mode.stop', t => { const mode = createMockMode(); delete mode.stop; - const mh = modeHandler(mode, createMockModeHandlerContext()); + const mh = modeHandler(mode, 'mode.stop', createMockModeHandlerContext()); t.doesNotThrow(() => { mh.stop(); @@ -160,7 +160,7 @@ test('ModeHandler#stop not calling nonexistent mode.stop', t => { test('Modehandler#trash', t => { const mode = createMockMode(); const drawContext = createMockModeHandlerContext(); - const mh = modeHandler(mode, drawContext); + const mh = modeHandler(mode, 'mode.trash', drawContext); mh.trash(); t.equal(mode.trash.callCount, 1, 'mode.trash called'); @@ -173,7 +173,7 @@ test('Modehandler#trash without a mode.trash', t => { const mode = createMockMode(); delete mode.trash; const drawContext = createMockModeHandlerContext(); - const mh = modeHandler(mode, drawContext); + const mh = modeHandler(mode, 'mode.trash', drawContext); t.doesNotThrow(() => { mh.trash();