Skip to content

Commit

Permalink
add Map#isZooming method (#6128)
Browse files Browse the repository at this point in the history
* add Map#isZooming method

* initialize Camera#zooming
  • Loading branch information
mollymerp authored Feb 12, 2018
1 parent b60a83c commit c015885
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
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

0 comments on commit c015885

Please sign in to comment.