Merge pull request #11815 from ahocevar/draw-regression

Remove unnecessary line that breaks drawing with multi-touch
This commit is contained in:
Andreas Hocevar
2020-12-08 22:49:10 +01:00
committed by GitHub
2 changed files with 14 additions and 3 deletions

View File

@@ -648,7 +648,6 @@ class Draw extends PointerInteraction {
if (!pass && this.stopClick_) {
event.stopPropagation();
}
this.downPx_ = null;
return pass;
}

View File

@@ -75,9 +75,10 @@ describe('ol.interaction.Draw', function () {
* @param {number} x Horizontal offset from map center.
* @param {number} y Vertical offset from map center.
* @param {boolean=} opt_shiftKey Shift key is pressed.
* @param {boolean=} opt_pointerId Pointer id.
* @return {module:ol/MapBrowserEvent} The simulated event.
*/
function simulateEvent(type, x, y, opt_shiftKey) {
function simulateEvent(type, x, y, opt_shiftKey, opt_pointerId = 0) {
const viewport = map.getViewport();
// calculated in case body has top < 0 (test runner with small window)
const position = viewport.getBoundingClientRect();
@@ -90,7 +91,7 @@ describe('ol.interaction.Draw', function () {
event.shiftKey = shiftKey;
event.preventDefault = function () {};
event.pointerType = 'mouse';
event.pointerId = 0;
event.pointerId = opt_pointerId;
const simulatedEvent = new MapBrowserEvent(type, map, event);
map.handleMapBrowserEvent(simulatedEvent);
return simulatedEvent;
@@ -219,6 +220,17 @@ describe('ol.interaction.Draw', function () {
expect(features).to.have.length(0);
});
it('does not draw a point when multiple pointers are involved', function () {
simulateEvent('pointerdown', 10, 20, false, 1);
simulateEvent('pointerdown', 10, 20, false, 2);
simulateEvent('pointermove', 10, 30, false, 1);
simulateEvent('pointermove', 10, 10, false, 2);
simulateEvent('pointerup', 10, 30, false, 1);
simulateEvent('pointerup', 10, 10, false, 2);
const features = source.getFeatures();
expect(features).to.have.length(0);
});
it('triggers draw events', function () {
const ds = sinon.spy();
const de = sinon.spy();