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

add Map#isZooming method #6128

Merged
merged 2 commits into from
Feb 12, 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
11 changes: 11 additions & 0 deletions src/ui/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class Camera extends Evented {
constructor(transform: Transform, options: {bearingSnap: number}) {
super();
this.moving = false;
this.zooming = false;
this.transform = transform;
this._bearingSnap = options.bearingSnap;
}
Expand Down Expand Up @@ -858,6 +859,16 @@ class Camera extends Evented {
return this.moving;
}

/**
* Returns a Boolean indicating whether the camera is zooming.
*
* @memberof Map#
* @returns A Boolean indicating whether the camera is zooming.
*/
isZooming(): boolean {
return this.zooming;
}

/**
* Stops any animated transition underway.
*
Expand Down
17 changes: 17 additions & 0 deletions test/unit/ui/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,23 @@ test('Map', (t) => {
map.zoomTo(5, { duration: 0 });
});

t.test('Map#isZooming', (t) => {
t.plan(3);
const map = createMap();

t.equal(map.isZooming(), false, 'false before zooming');

map.on('zoomstart', () => {
t.equal(map.isZooming(), true, 'true on zoomstart');
});

map.on('zoomend', () => {
t.equal(map.isZooming(), false, 'false on zoomend');
});

map.zoomTo(5, { duration: 0 });
});

t.end();
});

Expand Down