Merge pull request #812 from fredj/812

INTERACTION view hint ever growing on pinch zoom
This commit is contained in:
Frédéric Junod
2013-06-26 06:42:25 -07:00
7 changed files with 15 additions and 25 deletions
+3
View File
@@ -6,6 +6,7 @@ goog.require('goog.functions');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.MapBrowserEvent'); goog.require('ol.MapBrowserEvent');
goog.require('ol.MapBrowserEvent.EventType'); goog.require('ol.MapBrowserEvent.EventType');
goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
@@ -113,6 +114,7 @@ ol.interaction.Drag.prototype.handleMapBrowserEvent =
this.deltaX = browserEvent.clientX - this.startX; this.deltaX = browserEvent.clientX - this.startX;
this.deltaY = browserEvent.clientY - this.startY; this.deltaY = browserEvent.clientY - this.startY;
this.handleDragEnd(mapBrowserEvent); this.handleDragEnd(mapBrowserEvent);
view.setHint(ol.ViewHint.INTERACTING, -1);
this.dragging_ = false; this.dragging_ = false;
} }
} else if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DRAGSTART) { } else if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DRAGSTART) {
@@ -126,6 +128,7 @@ ol.interaction.Drag.prototype.handleMapBrowserEvent =
(mapBrowserEvent.getCoordinate()); (mapBrowserEvent.getCoordinate());
var handled = this.handleDragStart(mapBrowserEvent); var handled = this.handleDragStart(mapBrowserEvent);
if (handled) { if (handled) {
view.setHint(ol.ViewHint.INTERACTING, 1);
this.dragging_ = true; this.dragging_ = true;
mapBrowserEvent.preventDefault(); mapBrowserEvent.preventDefault();
mapBrowserEvent.stopOtherInteractions(); mapBrowserEvent.stopOtherInteractions();
+1 -5
View File
@@ -6,7 +6,6 @@ goog.require('goog.asserts');
goog.require('ol.Kinetic'); goog.require('ol.Kinetic');
goog.require('ol.PreRenderFunction'); goog.require('ol.PreRenderFunction');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.ViewHint');
goog.require('ol.coordinate'); goog.require('ol.coordinate');
goog.require('ol.interaction.ConditionType'); goog.require('ol.interaction.ConditionType');
goog.require('ol.interaction.Drag'); goog.require('ol.interaction.Drag');
@@ -82,7 +81,6 @@ ol.interaction.DragPan.prototype.handleDragEnd = function(mapBrowserEvent) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView(); var view = map.getView();
var interacting = view.setHint(ol.ViewHint.INTERACTING, -1);
if (this.kinetic_ && this.kinetic_.end()) { if (this.kinetic_ && this.kinetic_.end()) {
var distance = this.kinetic_.getDistance(); var distance = this.kinetic_.getDistance();
@@ -97,9 +95,8 @@ ol.interaction.DragPan.prototype.handleDragEnd = function(mapBrowserEvent) {
centerpx[1] - distance * Math.sin(angle) centerpx[1] - distance * Math.sin(angle)
]); ]);
view.setCenter(dest); view.setCenter(dest);
} else if (interacting === 0) {
map.requestRenderFrame();
} }
map.requestRenderFrame();
}; };
@@ -115,7 +112,6 @@ ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
} }
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
map.requestRenderFrame(); map.requestRenderFrame();
map.getView().setHint(ol.ViewHint.INTERACTING, 1);
return true; return true;
} else { } else {
return false; return false;
@@ -2,7 +2,6 @@ goog.provide('ol.interaction.DragRotate');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.ViewHint');
goog.require('ol.interaction.ConditionType'); goog.require('ol.interaction.ConditionType');
goog.require('ol.interaction.Drag'); goog.require('ol.interaction.Drag');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
@@ -76,7 +75,6 @@ ol.interaction.DragRotate.prototype.handleDragEnd = function(mapBrowserEvent) {
goog.asserts.assertInstanceof(view, ol.View2D); goog.asserts.assertInstanceof(view, ol.View2D);
ol.interaction.Interaction.rotate(map, view, view.getRotation(), undefined, ol.interaction.Interaction.rotate(map, view, view.getRotation(), undefined,
ol.interaction.DRAGROTATE_ANIMATION_DURATION); ol.interaction.DRAGROTATE_ANIMATION_DURATION);
view.setHint(ol.ViewHint.INTERACTING, -1);
}; };
@@ -93,7 +91,6 @@ ol.interaction.DragRotate.prototype.handleDragStart =
goog.asserts.assertInstanceof(view, ol.View2D); goog.asserts.assertInstanceof(view, ol.View2D);
map.requestRenderFrame(); map.requestRenderFrame();
this.lastAngle_ = undefined; this.lastAngle_ = undefined;
view.setHint(ol.ViewHint.INTERACTING, 1);
return true; return true;
} else { } else {
return false; return false;
+10 -1
View File
@@ -6,6 +6,7 @@ goog.require('goog.object');
goog.require('ol.MapBrowserEvent'); goog.require('ol.MapBrowserEvent');
goog.require('ol.MapBrowserEvent.EventType'); goog.require('ol.MapBrowserEvent.EventType');
goog.require('ol.Pixel'); goog.require('ol.Pixel');
goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
@@ -106,15 +107,23 @@ ol.interaction.Touch.prototype.handleTouchStart = goog.functions.FALSE;
*/ */
ol.interaction.Touch.prototype.handleMapBrowserEvent = ol.interaction.Touch.prototype.handleMapBrowserEvent =
function(mapBrowserEvent) { function(mapBrowserEvent) {
var view = mapBrowserEvent.map.getView();
this.updateTrackedTouches_(mapBrowserEvent); this.updateTrackedTouches_(mapBrowserEvent);
if (this.handled_) { if (this.handled_) {
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.TOUCHMOVE) { if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.TOUCHMOVE) {
this.handleTouchMove(mapBrowserEvent); this.handleTouchMove(mapBrowserEvent);
} else if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.TOUCHEND) { } else if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.TOUCHEND) {
this.handled_ = this.handleTouchEnd(mapBrowserEvent); this.handled_ = this.handleTouchEnd(mapBrowserEvent);
if (!this.handled_) {
view.setHint(ol.ViewHint.INTERACTING, -1);
}
} }
} }
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.TOUCHSTART) { 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;
} }
}; };
+1 -6
View File
@@ -5,8 +5,6 @@ goog.require('goog.asserts');
goog.require('ol.Kinetic'); goog.require('ol.Kinetic');
goog.require('ol.Pixel'); goog.require('ol.Pixel');
goog.require('ol.PreRenderFunction'); goog.require('ol.PreRenderFunction');
goog.require('ol.View');
goog.require('ol.ViewHint');
goog.require('ol.coordinate'); goog.require('ol.coordinate');
goog.require('ol.interaction.Touch'); goog.require('ol.interaction.Touch');
@@ -83,7 +81,6 @@ ol.interaction.TouchPan.prototype.handleTouchEnd =
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView(); var view = map.getView();
if (this.targetTouches.length === 0) { if (this.targetTouches.length === 0) {
var interacting = view.setHint(ol.ViewHint.INTERACTING, -1);
if (!this.noKinetic_ && this.kinetic_ && this.kinetic_.end()) { if (!this.noKinetic_ && this.kinetic_ && this.kinetic_.end()) {
var distance = this.kinetic_.getDistance(); var distance = this.kinetic_.getDistance();
var angle = this.kinetic_.getAngle(); var angle = this.kinetic_.getAngle();
@@ -96,9 +93,8 @@ ol.interaction.TouchPan.prototype.handleTouchEnd =
centerpx[1] - distance * Math.sin(angle) centerpx[1] - distance * Math.sin(angle)
]); ]);
view.setCenter(dest); view.setCenter(dest);
} else if (interacting === 0) {
map.requestRenderFrame();
} }
map.requestRenderFrame();
return false; return false;
} else { } else {
this.lastCentroid = null; this.lastCentroid = null;
@@ -125,7 +121,6 @@ ol.interaction.TouchPan.prototype.handleTouchStart =
if (this.kinetic_) { if (this.kinetic_) {
this.kinetic_.begin(); this.kinetic_.begin();
} }
view.setHint(ol.ViewHint.INTERACTING, 1);
// No kinetic as soon as more than one fingers on the screen is // No kinetic as soon as more than one fingers on the screen is
// detected. This is to prevent nasty pans after pinch. // detected. This is to prevent nasty pans after pinch.
this.noKinetic_ = this.targetTouches.length > 1; this.noKinetic_ = this.targetTouches.length > 1;
@@ -5,8 +5,6 @@ goog.provide('ol.interaction.TouchRotate');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.style'); goog.require('goog.style');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.View');
goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Touch'); goog.require('ol.interaction.Touch');
@@ -124,7 +122,6 @@ ol.interaction.TouchRotate.prototype.handleTouchEnd =
map, view, view.getRotation(), this.anchor_, map, view, view.getRotation(), this.anchor_,
ol.interaction.TOUCHROTATE_ANIMATION_DURATION); ol.interaction.TOUCHROTATE_ANIMATION_DURATION);
} }
view.setHint(ol.ViewHint.INTERACTING, -1);
return false; return false;
} else { } else {
return true; return true;
@@ -139,13 +136,11 @@ ol.interaction.TouchRotate.prototype.handleTouchStart =
function(mapBrowserEvent) { function(mapBrowserEvent) {
if (this.targetTouches.length >= 2) { if (this.targetTouches.length >= 2) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView();
this.anchor_ = null; this.anchor_ = null;
this.lastAngle_ = undefined; this.lastAngle_ = undefined;
this.rotating_ = false; this.rotating_ = false;
this.rotationDelta_ = 0.0; this.rotationDelta_ = 0.0;
map.requestRenderFrame(); map.requestRenderFrame();
view.setHint(ol.ViewHint.INTERACTING, 1);
return true; return true;
} else { } else {
return false; return false;
@@ -5,8 +5,6 @@ goog.provide('ol.interaction.TouchZoom');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.style'); goog.require('goog.style');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.View');
goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Touch'); goog.require('ol.interaction.Touch');
@@ -104,7 +102,6 @@ ol.interaction.TouchZoom.prototype.handleTouchEnd =
var direction = this.lastScaleDelta_ - 1; var direction = this.lastScaleDelta_ - 1;
ol.interaction.Interaction.zoom(map, view, view.getResolution(), ol.interaction.Interaction.zoom(map, view, view.getResolution(),
this.anchor_, ol.interaction.TOUCHZOOM_ANIMATION_DURATION, direction); this.anchor_, ol.interaction.TOUCHZOOM_ANIMATION_DURATION, direction);
view.setHint(ol.ViewHint.INTERACTING, -1);
return false; return false;
} else { } else {
return true; return true;
@@ -119,12 +116,10 @@ ol.interaction.TouchZoom.prototype.handleTouchStart =
function(mapBrowserEvent) { function(mapBrowserEvent) {
if (this.targetTouches.length >= 2) { if (this.targetTouches.length >= 2) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView();
this.anchor_ = null; this.anchor_ = null;
this.lastDistance_ = undefined; this.lastDistance_ = undefined;
this.lastScaleDelta_ = 1; this.lastScaleDelta_ = 1;
map.requestRenderFrame(); map.requestRenderFrame();
view.setHint(ol.ViewHint.INTERACTING, 1);
return true; return true;
} else { } else {
return false; return false;