Use requestRenderFrame API in interactions
This commit is contained in:
@@ -40,6 +40,7 @@ ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
|
|||||||
}
|
}
|
||||||
var newCenter = new ol.Coordinate(
|
var newCenter = new ol.Coordinate(
|
||||||
this.startCenter.x + delta.x, this.startCenter.y + delta.y);
|
this.startCenter.x + delta.x, this.startCenter.y + delta.y);
|
||||||
|
map.requestRenderFrame();
|
||||||
map.setCenter(newCenter);
|
map.setCenter(newCenter);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
|
|||||||
ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
|
ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
if (this.condition_(browserEvent)) {
|
if (this.condition_(browserEvent)) {
|
||||||
|
mapBrowserEvent.map.requestRenderFrame();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ ol.interaction.DragRotateAndZoom.prototype.handleDrag =
|
|||||||
size.height / 2 - browserEvent.offsetY);
|
size.height / 2 - browserEvent.offsetY);
|
||||||
var theta = Math.atan2(delta.y, delta.x);
|
var theta = Math.atan2(delta.y, delta.x);
|
||||||
// FIXME this should use map.withFrozenRendering but an assertion fails :-(
|
// FIXME this should use map.withFrozenRendering but an assertion fails :-(
|
||||||
|
map.requestRenderFrame();
|
||||||
map.rotate(this.startRotation_, -theta);
|
map.rotate(this.startRotation_, -theta);
|
||||||
var resolution = this.startRatio_ * delta.magnitude();
|
var resolution = this.startRatio_ * delta.magnitude();
|
||||||
map.zoomToResolution(resolution);
|
map.zoomToResolution(resolution);
|
||||||
@@ -73,6 +74,7 @@ ol.interaction.DragRotateAndZoom.prototype.handleDragStart =
|
|||||||
var theta = Math.atan2(delta.y, delta.x);
|
var theta = Math.atan2(delta.y, delta.x);
|
||||||
this.startRotation_ = (map.getRotation() || 0) + theta;
|
this.startRotation_ = (map.getRotation() || 0) + theta;
|
||||||
this.startRatio_ = resolution / delta.magnitude();
|
this.startRatio_ = resolution / delta.magnitude();
|
||||||
|
map.requestRenderFrame();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ ol.interaction.DragRotate.prototype.handleDrag = function(mapBrowserEvent) {
|
|||||||
var theta = Math.atan2(
|
var theta = Math.atan2(
|
||||||
size.height / 2 - offset.y,
|
size.height / 2 - offset.y,
|
||||||
offset.x - size.width / 2);
|
offset.x - size.width / 2);
|
||||||
|
map.requestRenderFrame();
|
||||||
map.rotate(this.startRotation_, -theta);
|
map.rotate(this.startRotation_, -theta);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ ol.interaction.DragRotate.prototype.handleDragStart =
|
|||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
if (browserEvent.isMouseActionButton() && this.condition_(browserEvent) &&
|
if (browserEvent.isMouseActionButton() && this.condition_(browserEvent) &&
|
||||||
map.canRotate()) {
|
map.canRotate()) {
|
||||||
|
map.requestRenderFrame();
|
||||||
var size = map.getSize();
|
var size = map.getSize();
|
||||||
var offset = mapBrowserEvent.getPixel();
|
var offset = mapBrowserEvent.getPixel();
|
||||||
var theta = Math.atan2(
|
var theta = Math.atan2(
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
|
|||||||
goog.asserts.assert(mouseWheelEvent instanceof goog.events.MouseWheelEvent);
|
goog.asserts.assert(mouseWheelEvent instanceof goog.events.MouseWheelEvent);
|
||||||
var anchor = mapBrowserEvent.getCoordinate();
|
var anchor = mapBrowserEvent.getCoordinate();
|
||||||
var delta = mouseWheelEvent.deltaY < 0 ? this.delta_ : -this.delta_;
|
var delta = mouseWheelEvent.deltaY < 0 ? this.delta_ : -this.delta_;
|
||||||
|
map.requestRenderFrame();
|
||||||
map.zoom(delta, anchor);
|
map.zoom(delta, anchor);
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
mouseWheelEvent.preventDefault();
|
mouseWheelEvent.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user