Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't stop camera on mousedown/touchstart when non-interactive #6338

Merged
merged 1 commit into from
Mar 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/ui/bind_handlers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// @flow

import { MapMouseEvent, MapTouchEvent, MapWheelEvent } from '../ui/events';

import DOM from '../util/dom';

import type Map from './map';

import scrollZoom from './handler/scroll_zoom';
import boxZoom from './handler/box_zoom';
import dragRotate from './handler/drag_rotate';
Expand Down Expand Up @@ -60,7 +57,7 @@ export default function bindHandlers(map: Map, options: {}) {
return;
}

if (!map.doubleClickZoom.isActive()) {
if (options.interactive && !map.doubleClickZoom.isActive()) {
map.stop();
}

Expand Down Expand Up @@ -120,7 +117,9 @@ export default function bindHandlers(map: Map, options: {}) {
return;
}

map.stop();
if (options.interactive) {
map.stop();
}

if (!map.boxZoom.isActive() && !map.dragRotate.isActive()) {
map.dragPan.onTouchStart(e);
Expand Down
46 changes: 46 additions & 0 deletions test/unit/ui/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import LngLat from '../../../src/geo/lng_lat';
import Tile from '../../../src/source/tile';
import { OverscaledTileID } from '../../../src/source/tile_id';
import { Event, ErrorEvent } from '../../../src/util/evented';
import simulate from 'mapbox-gl-js-test/simulate_interaction';

import fixed from 'mapbox-gl-js-test/fixed';
const fixedNum = fixed.Num;
const fixedLngLat = fixed.LngLat;
Expand Down Expand Up @@ -1296,6 +1298,50 @@ test('Map', (t) => {
});
});

t.test('stops camera animation on mousedown when interactive', (t) => {
const map = createMap({interactive: true});
map.flyTo({ center: [200, 0], duration: 100 });

simulate.mousedown(map.getCanvasContainer());
t.equal(map.isEasing(), false);

map.remove();
t.end();
});

t.test('continues camera animation on mousedown when non-interactive', (t) => {
const map = createMap({interactive: false});
map.flyTo({ center: [200, 0], duration: 100 });

simulate.mousedown(map.getCanvasContainer());
t.equal(map.isEasing(), true);

map.remove();
t.end();
});

t.test('stops camera animation on touchstart when interactive', (t) => {
const map = createMap({interactive: true});
map.flyTo({ center: [200, 0], duration: 100 });

simulate.touchstart(map.getCanvasContainer());
t.equal(map.isEasing(), false);

map.remove();
t.end();
});

t.test('continues camera animation on touchstart when non-interactive', (t) => {
const map = createMap({interactive: false});
map.flyTo({ center: [200, 0], duration: 100 });

simulate.touchstart(map.getCanvasContainer());
t.equal(map.isEasing(), true);

map.remove();
t.end();
});

t.end();
});

Expand Down