-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure drag handlers request render frames on move (#6068)
Closes #6063 Caused by #6005 because, after that change, the drag handlers relied on the `move` event to trigger a map rerender to pick up the next batch of mouse movements. This worked fine while dragging was in progress, but after the user paused and the render frame triggered by the last `move` event was complete, there was nothing to re-initiate the render loop once the mouse moved again.
- Loading branch information
1 parent
e66651e
commit 6600374
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
const test = require('mapbox-gl-js-test').test; | ||
const util = require('../../../../src/util/util'); | ||
const window = require('../../../../src/util/window'); | ||
const Map = require('../../../../src/ui/map'); | ||
const DOM = require('../../../../src/util/dom'); | ||
const simulate = require('mapbox-gl-js-test/simulate_interaction'); | ||
|
||
function createMap(options) { | ||
return new Map(util.extend({ | ||
container: DOM.create('div', '', window.document.body), | ||
style: { | ||
"version": 8, | ||
"sources": {}, | ||
"layers": [] | ||
} | ||
}, options)); | ||
} | ||
|
||
test('DragPanHandler requests a new render frame after each mousemove event', (t) => { | ||
const map = createMap(); | ||
const update = t.spy(map, '_update'); | ||
|
||
simulate.mousedown(map.getCanvas(), {bubbles: true, buttons: 2}); | ||
simulate.mousemove(map.getCanvas(), {bubbles: true, buttons: 2}); | ||
t.ok(update.callCount > 0); | ||
|
||
// https://github.com/mapbox/mapbox-gl-js/issues/6063 | ||
update.reset(); | ||
simulate.mousemove(map.getCanvas(), {bubbles: true, buttons: 2}); | ||
t.equal(update.callCount, 1); | ||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters