Merge pull request #528 from elemoine/touch

Touch interactions should use requestRenderFrame
This commit is contained in:
Éric Lemoine
2013-04-10 22:44:27 -07:00
4 changed files with 12 additions and 9 deletions

View File

@@ -33,7 +33,6 @@ ol.interaction.Interaction.pan = function(
var currentCenter = view.getCenter();
if (goog.isDef(currentCenter)) {
if (goog.isDef(opt_duration)) {
map.requestRenderFrame();
map.addPreRenderFunction(ol.animation.pan({
source: currentCenter,
duration: opt_duration,
@@ -74,7 +73,6 @@ ol.interaction.Interaction.rotateWithoutConstraints =
var currentCenter = view.getCenter();
if (goog.isDef(currentRotation) && goog.isDef(currentCenter) &&
goog.isDef(opt_duration)) {
map.requestRenderFrame();
map.addPreRenderFunction(ol.animation.rotate({
rotation: currentRotation,
duration: opt_duration,
@@ -154,7 +152,6 @@ ol.interaction.Interaction.zoomWithoutConstraints =
var currentCenter = view.getCenter();
if (goog.isDef(currentResolution) && goog.isDef(currentCenter) &&
goog.isDef(opt_duration)) {
map.requestRenderFrame();
map.addPreRenderFunction(ol.animation.zoom({
resolution: currentResolution,
duration: opt_duration,

View File

@@ -60,11 +60,13 @@ ol.interaction.TouchPan.prototype.handleTouchMove = function(mapBrowserEvent) {
}
var deltaX = this.lastCentroid.x - centroid.x;
var deltaY = centroid.y - this.lastCentroid.y;
var view = mapBrowserEvent.map.getView();
var map = mapBrowserEvent.map;
var view = map.getView();
var center = [deltaX, deltaY];
ol.coordinate.scale(center, view.getResolution());
ol.coordinate.rotate(center, view.getRotation());
ol.coordinate.add(center, view.getCenter());
map.requestRenderFrame();
view.setCenter(center);
}
this.lastCentroid = centroid;
@@ -110,9 +112,9 @@ ol.interaction.TouchPan.prototype.handleTouchStart =
var map = mapBrowserEvent.map;
var view = map.getView();
this.lastCentroid = null;
map.requestRenderFrame();
if (!goog.isNull(this.kineticPreRenderFn_) &&
map.removePreRenderFunction(this.kineticPreRenderFn_)) {
map.requestRenderFrame();
view.setCenter(mapBrowserEvent.frameState.view2DState.center);
this.kineticPreRenderFn_ = null;
}

View File

@@ -17,8 +17,6 @@ ol.interaction.TOUCHROTATE_ANIMATION_DURATION = 250;
/**
/**
* @constructor
* @extends {ol.interaction.Touch}
@@ -100,6 +98,7 @@ ol.interaction.TouchRotate.prototype.handleTouchMove =
// rotate
if (this.rotating_) {
var view = map.getView().getView2D();
map.requestRenderFrame();
ol.interaction.Interaction.rotateWithoutConstraints(map, view,
view.getRotation() + rotationDelta, anchor);
}
@@ -133,10 +132,12 @@ ol.interaction.TouchRotate.prototype.handleTouchEnd =
ol.interaction.TouchRotate.prototype.handleTouchStart =
function(mapBrowserEvent) {
if (this.targetTouches.length >= 2) {
var view = mapBrowserEvent.map.getView();
var map = mapBrowserEvent.map;
var view = map.getView();
this.lastAngle_ = undefined;
this.rotating_ = false;
this.rotationDelta_ = 0.0;
map.requestRenderFrame();
view.setHint(ol.ViewHint.INTERACTING, 1);
return true;
} else {

View File

@@ -76,6 +76,7 @@ ol.interaction.TouchZoom.prototype.handleTouchMove =
var anchor = map.getCoordinateFromPixel(centroid);
// scale, bypass the resolution constraint
map.requestRenderFrame();
ol.interaction.Interaction.zoomWithoutConstraints(
map, view, view.getResolution() * scaleDelta, anchor);
@@ -110,9 +111,11 @@ ol.interaction.TouchZoom.prototype.handleTouchEnd =
ol.interaction.TouchZoom.prototype.handleTouchStart =
function(mapBrowserEvent) {
if (this.targetTouches.length >= 2) {
var view = mapBrowserEvent.map.getView();
var map = mapBrowserEvent.map;
var view = map.getView();
this.lastDistance_ = undefined;
this.lastScaleDelta_ = 1;
map.requestRenderFrame();
view.setHint(ol.ViewHint.INTERACTING, 1);
return true;
} else {