Merge pull request #6764 from mblinsitu/getInteracting

Added View#getInteracting() to the api
This commit is contained in:
Frédéric Junod
2017-05-02 10:35:53 +02:00
committed by GitHub
2 changed files with 13 additions and 0 deletions

View File

@@ -317,6 +317,16 @@ ol.View.prototype.getAnimating = function() {
};
/**
* Determine if the user is interacting with the view, such as panning or zooming.
* @return {boolean} The view is being interacted with.
* @api
*/
ol.View.prototype.getInteracting = function() {
return this.getHints()[ol.ViewHint.INTERACTING] > 0;
};
/**
* Cancel any ongoing animations.
* @api

View File

@@ -310,9 +310,11 @@ describe('ol.View', function() {
});
expect(view.getHints()).to.eql([0, 0]);
expect(view.getInteracting()).to.eql(false);
view.setHint(ol.ViewHint.INTERACTING, 1);
expect(view.getHints()).to.eql([0, 1]);
expect(view.getInteracting()).to.eql(true);
});
it('triggers the change event', function(done) {
@@ -323,6 +325,7 @@ describe('ol.View', function() {
view.on('change', function() {
expect(view.getHints()).to.eql([0, 1]);
expect(view.getInteracting()).to.eql(true);
done();
});
view.setHint(ol.ViewHint.INTERACTING, 1);