From 87dda95b18f2dc91891c77710cbda49f4db7ba66 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 25 Jun 2013 12:24:51 +0200 Subject: [PATCH] Handle ol.ViewHint.INTERACTING in ol.interaction.Touch --- src/ol/interaction/touchinteraction.js | 11 ++++++++++- src/ol/interaction/touchpaninteraction.js | 7 +------ src/ol/interaction/touchrotateinteraction.js | 5 ----- src/ol/interaction/touchzoominteraction.js | 5 ----- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/ol/interaction/touchinteraction.js b/src/ol/interaction/touchinteraction.js index 60a57ffe48..b19b1e5d51 100644 --- a/src/ol/interaction/touchinteraction.js +++ b/src/ol/interaction/touchinteraction.js @@ -6,6 +6,7 @@ goog.require('goog.object'); goog.require('ol.MapBrowserEvent'); goog.require('ol.MapBrowserEvent.EventType'); goog.require('ol.Pixel'); +goog.require('ol.ViewHint'); goog.require('ol.interaction.Interaction'); @@ -106,15 +107,23 @@ ol.interaction.Touch.prototype.handleTouchStart = goog.functions.FALSE; */ ol.interaction.Touch.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { + var view = mapBrowserEvent.map.getView(); this.updateTrackedTouches_(mapBrowserEvent); if (this.handled_) { if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.TOUCHMOVE) { this.handleTouchMove(mapBrowserEvent); } else if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.TOUCHEND) { this.handled_ = this.handleTouchEnd(mapBrowserEvent); + if (!this.handled_) { + view.setHint(ol.ViewHint.INTERACTING, -1); + } } } if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.TOUCHSTART) { - this.handled_ = this.handleTouchStart(mapBrowserEvent); + var handled = this.handleTouchStart(mapBrowserEvent); + if (!this.handled_ && handled) { + view.setHint(ol.ViewHint.INTERACTING, 1); + } + this.handled_ = handled; } }; diff --git a/src/ol/interaction/touchpaninteraction.js b/src/ol/interaction/touchpaninteraction.js index a13585c0d4..b9ef2678ca 100644 --- a/src/ol/interaction/touchpaninteraction.js +++ b/src/ol/interaction/touchpaninteraction.js @@ -5,8 +5,6 @@ goog.require('goog.asserts'); goog.require('ol.Kinetic'); goog.require('ol.Pixel'); goog.require('ol.PreRenderFunction'); -goog.require('ol.View'); -goog.require('ol.ViewHint'); goog.require('ol.coordinate'); goog.require('ol.interaction.Touch'); @@ -83,7 +81,6 @@ ol.interaction.TouchPan.prototype.handleTouchEnd = var map = mapBrowserEvent.map; var view = map.getView(); if (this.targetTouches.length === 0) { - var interacting = view.setHint(ol.ViewHint.INTERACTING, -1); if (!this.noKinetic_ && this.kinetic_ && this.kinetic_.end()) { var distance = this.kinetic_.getDistance(); var angle = this.kinetic_.getAngle(); @@ -96,9 +93,8 @@ ol.interaction.TouchPan.prototype.handleTouchEnd = centerpx[1] - distance * Math.sin(angle) ]); view.setCenter(dest); - } else if (interacting === 0) { - map.requestRenderFrame(); } + map.requestRenderFrame(); return false; } else { this.lastCentroid = null; @@ -125,7 +121,6 @@ ol.interaction.TouchPan.prototype.handleTouchStart = if (this.kinetic_) { this.kinetic_.begin(); } - view.setHint(ol.ViewHint.INTERACTING, 1); // No kinetic as soon as more than one fingers on the screen is // detected. This is to prevent nasty pans after pinch. this.noKinetic_ = this.targetTouches.length > 1; diff --git a/src/ol/interaction/touchrotateinteraction.js b/src/ol/interaction/touchrotateinteraction.js index b9069a963a..4421695742 100644 --- a/src/ol/interaction/touchrotateinteraction.js +++ b/src/ol/interaction/touchrotateinteraction.js @@ -5,8 +5,6 @@ goog.provide('ol.interaction.TouchRotate'); goog.require('goog.asserts'); goog.require('goog.style'); goog.require('ol.Coordinate'); -goog.require('ol.View'); -goog.require('ol.ViewHint'); goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Touch'); @@ -124,7 +122,6 @@ ol.interaction.TouchRotate.prototype.handleTouchEnd = map, view, view.getRotation(), this.anchor_, ol.interaction.TOUCHROTATE_ANIMATION_DURATION); } - view.setHint(ol.ViewHint.INTERACTING, -1); return false; } else { return true; @@ -139,13 +136,11 @@ ol.interaction.TouchRotate.prototype.handleTouchStart = function(mapBrowserEvent) { if (this.targetTouches.length >= 2) { var map = mapBrowserEvent.map; - var view = map.getView(); this.anchor_ = null; this.lastAngle_ = undefined; this.rotating_ = false; this.rotationDelta_ = 0.0; map.requestRenderFrame(); - view.setHint(ol.ViewHint.INTERACTING, 1); return true; } else { return false; diff --git a/src/ol/interaction/touchzoominteraction.js b/src/ol/interaction/touchzoominteraction.js index 5bb24a161c..2a95e6d842 100644 --- a/src/ol/interaction/touchzoominteraction.js +++ b/src/ol/interaction/touchzoominteraction.js @@ -5,8 +5,6 @@ goog.provide('ol.interaction.TouchZoom'); goog.require('goog.asserts'); goog.require('goog.style'); goog.require('ol.Coordinate'); -goog.require('ol.View'); -goog.require('ol.ViewHint'); goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Touch'); @@ -104,7 +102,6 @@ ol.interaction.TouchZoom.prototype.handleTouchEnd = var direction = this.lastScaleDelta_ - 1; ol.interaction.Interaction.zoom(map, view, view.getResolution(), this.anchor_, ol.interaction.TOUCHZOOM_ANIMATION_DURATION, direction); - view.setHint(ol.ViewHint.INTERACTING, -1); return false; } else { return true; @@ -119,12 +116,10 @@ ol.interaction.TouchZoom.prototype.handleTouchStart = function(mapBrowserEvent) { if (this.targetTouches.length >= 2) { var map = mapBrowserEvent.map; - var view = map.getView(); this.anchor_ = null; this.lastDistance_ = undefined; this.lastScaleDelta_ = 1; map.requestRenderFrame(); - view.setHint(ol.ViewHint.INTERACTING, 1); return true; } else { return false;