Merge pull request #528 from elemoine/touch
Touch interactions should use requestRenderFrame
This commit is contained in:
@@ -33,7 +33,6 @@ ol.interaction.Interaction.pan = function(
|
|||||||
var currentCenter = view.getCenter();
|
var currentCenter = view.getCenter();
|
||||||
if (goog.isDef(currentCenter)) {
|
if (goog.isDef(currentCenter)) {
|
||||||
if (goog.isDef(opt_duration)) {
|
if (goog.isDef(opt_duration)) {
|
||||||
map.requestRenderFrame();
|
|
||||||
map.addPreRenderFunction(ol.animation.pan({
|
map.addPreRenderFunction(ol.animation.pan({
|
||||||
source: currentCenter,
|
source: currentCenter,
|
||||||
duration: opt_duration,
|
duration: opt_duration,
|
||||||
@@ -74,7 +73,6 @@ ol.interaction.Interaction.rotateWithoutConstraints =
|
|||||||
var currentCenter = view.getCenter();
|
var currentCenter = view.getCenter();
|
||||||
if (goog.isDef(currentRotation) && goog.isDef(currentCenter) &&
|
if (goog.isDef(currentRotation) && goog.isDef(currentCenter) &&
|
||||||
goog.isDef(opt_duration)) {
|
goog.isDef(opt_duration)) {
|
||||||
map.requestRenderFrame();
|
|
||||||
map.addPreRenderFunction(ol.animation.rotate({
|
map.addPreRenderFunction(ol.animation.rotate({
|
||||||
rotation: currentRotation,
|
rotation: currentRotation,
|
||||||
duration: opt_duration,
|
duration: opt_duration,
|
||||||
@@ -154,7 +152,6 @@ ol.interaction.Interaction.zoomWithoutConstraints =
|
|||||||
var currentCenter = view.getCenter();
|
var currentCenter = view.getCenter();
|
||||||
if (goog.isDef(currentResolution) && goog.isDef(currentCenter) &&
|
if (goog.isDef(currentResolution) && goog.isDef(currentCenter) &&
|
||||||
goog.isDef(opt_duration)) {
|
goog.isDef(opt_duration)) {
|
||||||
map.requestRenderFrame();
|
|
||||||
map.addPreRenderFunction(ol.animation.zoom({
|
map.addPreRenderFunction(ol.animation.zoom({
|
||||||
resolution: currentResolution,
|
resolution: currentResolution,
|
||||||
duration: opt_duration,
|
duration: opt_duration,
|
||||||
|
|||||||
@@ -60,11 +60,13 @@ ol.interaction.TouchPan.prototype.handleTouchMove = function(mapBrowserEvent) {
|
|||||||
}
|
}
|
||||||
var deltaX = this.lastCentroid.x - centroid.x;
|
var deltaX = this.lastCentroid.x - centroid.x;
|
||||||
var deltaY = centroid.y - this.lastCentroid.y;
|
var deltaY = centroid.y - this.lastCentroid.y;
|
||||||
var view = mapBrowserEvent.map.getView();
|
var map = mapBrowserEvent.map;
|
||||||
|
var view = map.getView();
|
||||||
var center = [deltaX, deltaY];
|
var center = [deltaX, deltaY];
|
||||||
ol.coordinate.scale(center, view.getResolution());
|
ol.coordinate.scale(center, view.getResolution());
|
||||||
ol.coordinate.rotate(center, view.getRotation());
|
ol.coordinate.rotate(center, view.getRotation());
|
||||||
ol.coordinate.add(center, view.getCenter());
|
ol.coordinate.add(center, view.getCenter());
|
||||||
|
map.requestRenderFrame();
|
||||||
view.setCenter(center);
|
view.setCenter(center);
|
||||||
}
|
}
|
||||||
this.lastCentroid = centroid;
|
this.lastCentroid = centroid;
|
||||||
@@ -110,9 +112,9 @@ ol.interaction.TouchPan.prototype.handleTouchStart =
|
|||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
this.lastCentroid = null;
|
this.lastCentroid = null;
|
||||||
|
map.requestRenderFrame();
|
||||||
if (!goog.isNull(this.kineticPreRenderFn_) &&
|
if (!goog.isNull(this.kineticPreRenderFn_) &&
|
||||||
map.removePreRenderFunction(this.kineticPreRenderFn_)) {
|
map.removePreRenderFunction(this.kineticPreRenderFn_)) {
|
||||||
map.requestRenderFrame();
|
|
||||||
view.setCenter(mapBrowserEvent.frameState.view2DState.center);
|
view.setCenter(mapBrowserEvent.frameState.view2DState.center);
|
||||||
this.kineticPreRenderFn_ = null;
|
this.kineticPreRenderFn_ = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ ol.interaction.TOUCHROTATE_ANIMATION_DURATION = 250;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.interaction.Touch}
|
* @extends {ol.interaction.Touch}
|
||||||
@@ -100,6 +98,7 @@ ol.interaction.TouchRotate.prototype.handleTouchMove =
|
|||||||
// rotate
|
// rotate
|
||||||
if (this.rotating_) {
|
if (this.rotating_) {
|
||||||
var view = map.getView().getView2D();
|
var view = map.getView().getView2D();
|
||||||
|
map.requestRenderFrame();
|
||||||
ol.interaction.Interaction.rotateWithoutConstraints(map, view,
|
ol.interaction.Interaction.rotateWithoutConstraints(map, view,
|
||||||
view.getRotation() + rotationDelta, anchor);
|
view.getRotation() + rotationDelta, anchor);
|
||||||
}
|
}
|
||||||
@@ -133,10 +132,12 @@ ol.interaction.TouchRotate.prototype.handleTouchEnd =
|
|||||||
ol.interaction.TouchRotate.prototype.handleTouchStart =
|
ol.interaction.TouchRotate.prototype.handleTouchStart =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
if (this.targetTouches.length >= 2) {
|
if (this.targetTouches.length >= 2) {
|
||||||
var view = mapBrowserEvent.map.getView();
|
var map = mapBrowserEvent.map;
|
||||||
|
var view = map.getView();
|
||||||
this.lastAngle_ = undefined;
|
this.lastAngle_ = undefined;
|
||||||
this.rotating_ = false;
|
this.rotating_ = false;
|
||||||
this.rotationDelta_ = 0.0;
|
this.rotationDelta_ = 0.0;
|
||||||
|
map.requestRenderFrame();
|
||||||
view.setHint(ol.ViewHint.INTERACTING, 1);
|
view.setHint(ol.ViewHint.INTERACTING, 1);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ ol.interaction.TouchZoom.prototype.handleTouchMove =
|
|||||||
var anchor = map.getCoordinateFromPixel(centroid);
|
var anchor = map.getCoordinateFromPixel(centroid);
|
||||||
|
|
||||||
// scale, bypass the resolution constraint
|
// scale, bypass the resolution constraint
|
||||||
|
map.requestRenderFrame();
|
||||||
ol.interaction.Interaction.zoomWithoutConstraints(
|
ol.interaction.Interaction.zoomWithoutConstraints(
|
||||||
map, view, view.getResolution() * scaleDelta, anchor);
|
map, view, view.getResolution() * scaleDelta, anchor);
|
||||||
|
|
||||||
@@ -110,9 +111,11 @@ ol.interaction.TouchZoom.prototype.handleTouchEnd =
|
|||||||
ol.interaction.TouchZoom.prototype.handleTouchStart =
|
ol.interaction.TouchZoom.prototype.handleTouchStart =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
if (this.targetTouches.length >= 2) {
|
if (this.targetTouches.length >= 2) {
|
||||||
var view = mapBrowserEvent.map.getView();
|
var map = mapBrowserEvent.map;
|
||||||
|
var view = map.getView();
|
||||||
this.lastDistance_ = undefined;
|
this.lastDistance_ = undefined;
|
||||||
this.lastScaleDelta_ = 1;
|
this.lastScaleDelta_ = 1;
|
||||||
|
map.requestRenderFrame();
|
||||||
view.setHint(ol.ViewHint.INTERACTING, 1);
|
view.setHint(ol.ViewHint.INTERACTING, 1);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user