Merge pull request #6486 from ahocevar/reset-on-pointer-count-change
Do not set center when touches count has changed
This commit is contained in:
@@ -39,6 +39,11 @@ ol.interaction.DragPan = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.lastCentroid = null;
|
this.lastCentroid = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.lastPointersCount_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.EventsConditionType}
|
* @type {ol.EventsConditionType}
|
||||||
@@ -62,25 +67,33 @@ ol.inherits(ol.interaction.DragPan, ol.interaction.Pointer);
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) {
|
ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) {
|
||||||
|
var targetPointers = this.targetPointers;
|
||||||
var centroid =
|
var centroid =
|
||||||
ol.interaction.Pointer.centroid(this.targetPointers);
|
ol.interaction.Pointer.centroid(targetPointers);
|
||||||
if (this.kinetic_) {
|
if (targetPointers.length == this.lastPointersCount_) {
|
||||||
this.kinetic_.update(centroid[0], centroid[1]);
|
if (this.kinetic_) {
|
||||||
}
|
this.kinetic_.update(centroid[0], centroid[1]);
|
||||||
if (this.lastCentroid) {
|
}
|
||||||
var deltaX = this.lastCentroid[0] - centroid[0];
|
if (this.lastCentroid) {
|
||||||
var deltaY = centroid[1] - this.lastCentroid[1];
|
var deltaX = this.lastCentroid[0] - centroid[0];
|
||||||
var map = mapBrowserEvent.map;
|
var deltaY = centroid[1] - this.lastCentroid[1];
|
||||||
var view = map.getView();
|
var map = mapBrowserEvent.map;
|
||||||
var viewState = view.getState();
|
var view = map.getView();
|
||||||
var center = [deltaX, deltaY];
|
var viewState = view.getState();
|
||||||
ol.coordinate.scale(center, viewState.resolution);
|
var center = [deltaX, deltaY];
|
||||||
ol.coordinate.rotate(center, viewState.rotation);
|
ol.coordinate.scale(center, viewState.resolution);
|
||||||
ol.coordinate.add(center, viewState.center);
|
ol.coordinate.rotate(center, viewState.rotation);
|
||||||
center = view.constrainCenter(center);
|
ol.coordinate.add(center, viewState.center);
|
||||||
view.setCenter(center);
|
center = view.constrainCenter(center);
|
||||||
|
view.setCenter(center);
|
||||||
|
}
|
||||||
|
} else if (this.kinetic_) {
|
||||||
|
// reset so we don't overestimate the kinetic energy after
|
||||||
|
// after one finger down, tiny drag, second finger down
|
||||||
|
this.kinetic_.begin();
|
||||||
}
|
}
|
||||||
this.lastCentroid = centroid;
|
this.lastCentroid = centroid;
|
||||||
|
this.lastPointersCount_ = targetPointers.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user