Merge pull request #6121 from tschaub/hint-change-means-view-change
Hint change means view change
This commit is contained in:
@@ -110,9 +110,6 @@ ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
duration: 500,
|
||||
easing: ol.easing.easeOut
|
||||
});
|
||||
} else {
|
||||
// the view is not updated, force a render
|
||||
map.render();
|
||||
}
|
||||
view.setHint(ol.View.Hint.INTERACTING, -1);
|
||||
return false;
|
||||
|
||||
@@ -223,7 +223,6 @@ ol.interaction.MouseWheelZoom.prototype.decrementInteractingHint_ = function() {
|
||||
this.trackpadTimeoutId_ = undefined;
|
||||
var view = this.getMap().getView();
|
||||
view.setHint(ol.View.Hint.INTERACTING, -1);
|
||||
view.changed(); // notify listeners of the hint change
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -157,7 +157,6 @@ ol.interaction.PinchRotate.handleDownEvent_ = function(mapBrowserEvent) {
|
||||
if (!this.handlingDownUpSequence) {
|
||||
map.getView().setHint(ol.View.Hint.INTERACTING, 1);
|
||||
}
|
||||
map.render();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -140,7 +140,6 @@ ol.interaction.PinchZoom.handleDownEvent_ = function(mapBrowserEvent) {
|
||||
if (!this.handlingDownUpSequence) {
|
||||
map.getView().setHint(ol.View.Hint.INTERACTING, 1);
|
||||
}
|
||||
map.render();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -280,7 +280,6 @@ ol.View.prototype.cancelAnimations = function() {
|
||||
}
|
||||
}
|
||||
this.animations_.length = 0;
|
||||
this.changed(); // notify that the hint changed
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -826,6 +825,7 @@ ol.View.prototype.setHint = function(hint, delta) {
|
||||
this.hints_[hint] += delta;
|
||||
ol.DEBUG && console.assert(this.hints_[hint] >= 0,
|
||||
'Hint at %s must be positive, was %s', hint, this.hints_[hint]);
|
||||
this.changed();
|
||||
return this.hints_[hint];
|
||||
};
|
||||
|
||||
|
||||
@@ -301,6 +301,35 @@ describe('ol.View', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#setHint()', function() {
|
||||
|
||||
it('changes a view hint', function() {
|
||||
var view = new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
});
|
||||
|
||||
expect(view.getHints()).to.eql([0, 0]);
|
||||
|
||||
view.setHint(ol.View.Hint.INTERACTING, 1);
|
||||
expect(view.getHints()).to.eql([0, 1]);
|
||||
});
|
||||
|
||||
it('triggers the change event', function(done) {
|
||||
var view = new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
});
|
||||
|
||||
view.on('change', function() {
|
||||
expect(view.getHints()).to.eql([0, 1]);
|
||||
done();
|
||||
});
|
||||
view.setHint(ol.View.Hint.INTERACTING, 1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#animate()', function() {
|
||||
|
||||
var originalRequestAnimationFrame = window.requestAnimationFrame;
|
||||
|
||||
Reference in New Issue
Block a user