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

Fix #4337 eventData not passed during flyTo #4342

Merged
merged 1 commit into from
Feb 28, 2017
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
2 changes: 1 addition & 1 deletion src/ui/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ class Camera extends Evented {
// When u₀ = u₁, the optimal path doesn’t require both ascent and descent.
if (Math.abs(u1) < 0.000001) {
// Perform a more or less instantaneous transition if the path is too short.
if (Math.abs(w0 - w1) < 0.000001) return this.easeTo(options);
if (Math.abs(w0 - w1) < 0.000001) return this.easeTo(options, eventData);

const k = w1 < w0 ? -1 : 1;
S = Math.abs(Math.log(w1 / w0)) / rho;
Expand Down
35 changes: 35 additions & 0 deletions test/unit/ui/camera.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,41 @@ test('camera', (t) => {
eventData);
});

t.test('for short flights, emits (solely) move events, preserving eventData', (t) => {
//As I type this, the code path for guiding super-short flights is (and will probably remain) different.
//As such; it deserves a separate test case. This test case flies the map from A to A.
const fromTo = { center: [100, 0] };
const camera = createCamera(fromTo);
let movestarted, moved, rotated, pitched, zoomstarted, zoomed, zoomended;
const eventData = { data: 'ok' };

camera
.on('movestart', (d) => { movestarted = d.data; })
.on('move', (d) => { moved = d.data; })
.on('rotate', (d) => { rotated = d.data; })
.on('pitch', (d) => { pitched = d.data; })
.on('zoomstart', (d) => { zoomstarted = d.data; })
.on('zoom', (d) => { zoomed = d.data; })
.on('zoomend', (d) => { zoomended = d.data; })
.on('moveend', function(d) {
t.notOk(this.zooming);
t.notOk(this.panning);
t.notOk(this.rotating);

t.equal(movestarted, 'ok');
t.equal(moved, 'ok');
t.equal(zoomstarted, undefined);
t.equal(zoomed, undefined);
t.equal(zoomended, undefined);
t.equal(rotated, undefined);
t.equal(pitched, undefined);
t.equal(d.data, 'ok');
t.end();
});

camera.flyTo(fromTo, eventData);
});

t.test('stops existing ease', (t) => {
const camera = createCamera();
camera.flyTo({ center: [200, 0], duration: 100 });
Expand Down