Rename interactions

The idea behind the naming scheme is that for example
for `DragRotate`, `Rotate` is the action and `Drag` the
gesture that issues the action.
This commit is contained in:
tsauerwein
2014-03-12 15:10:17 +01:00
parent ee80238ed2
commit 5a358918e1
12 changed files with 50 additions and 48 deletions

View File

@@ -432,10 +432,12 @@
* desired. Default is `true`.
* @property {boolean|undefined} shiftDragZoom Whether Shift-drag zoom is
* desired. Default is `true`.
* @property {boolean|undefined} pan Whether pan is
* @property {boolean|undefined} dragPan Whether drag pan is
* desired. Default is `true`.
* @property {boolean|undefined} pinchRotate Whether pinch rotate is
* desired. Default is `true`.
* @property {boolean|undefined} pinchZoom Whether pinch zoom is
* desired. Default is `true`.
* @property {boolean|undefined} rotate Whether rotate is desired. Default is `true`.
* @property {boolean|undefined} zoom Whether zoom is desired. Default is `true`.
* @property {number|undefined} zoomDelta Zoom delta.
* @property {number|undefined} zoomDuration Zoom duration.
* @todo stability experimental
@@ -502,7 +504,7 @@
*/
/**
* @typedef {Object} olx.interaction.PanOptions
* @typedef {Object} olx.interaction.DragPanOptions
* @property {ol.Kinetic|undefined} kinetic Kinetic inertia to apply to the
* pan.
* @todo stability experimental
@@ -517,14 +519,14 @@
*/
/**
* @typedef {Object} olx.interaction.RotateOptions
* @typedef {Object} olx.interaction.PinchRotateOptions
* @property {number|undefined} threshold Minimal angle in radians to start a rotation.
* Default is `0.3`.
* @todo stability experimental
*/
/**
* @typedef {Object} olx.interaction.ZoomOptions
* @typedef {Object} olx.interaction.PinchZoomOptions
* @property {number|undefined} duration Animation duration in milliseconds. Default is `400`.
* @todo stability experimental
*/

View File

@@ -0,0 +1 @@
@exportSymbol ol.interaction.DragPan

View File

@@ -1,5 +1,5 @@
// FIXME works for View2D only
goog.provide('ol.interaction.Pan');
goog.provide('ol.interaction.DragPan');
goog.require('goog.asserts');
goog.require('ol.Kinetic');
@@ -16,10 +16,10 @@ goog.require('ol.interaction.Pointer');
* Allows the user to pan the map by dragging the map.
* @constructor
* @extends {ol.interaction.Pointer}
* @param {olx.interaction.PanOptions=} opt_options Options.
* @param {olx.interaction.DragPanOptions=} opt_options Options.
* @todo stability experimental
*/
ol.interaction.Pan = function(opt_options) {
ol.interaction.DragPan = function(opt_options) {
goog.base(this);
@@ -56,13 +56,13 @@ ol.interaction.Pan = function(opt_options) {
this.noKinetic_ = false;
};
goog.inherits(ol.interaction.Pan, ol.interaction.Pointer);
goog.inherits(ol.interaction.DragPan, ol.interaction.Pointer);
/**
* @inheritDoc
*/
ol.interaction.Pan.prototype.handlePointerDrag = function(mapBrowserEvent) {
ol.interaction.DragPan.prototype.handlePointerDrag = function(mapBrowserEvent) {
goog.asserts.assert(this.targetPointers.length >= 1);
var centroid =
ol.interaction.Pointer.centroid(this.targetPointers);
@@ -91,7 +91,7 @@ ol.interaction.Pan.prototype.handlePointerDrag = function(mapBrowserEvent) {
/**
* @inheritDoc
*/
ol.interaction.Pan.prototype.handlePointerUp =
ol.interaction.DragPan.prototype.handlePointerUp =
function(mapBrowserEvent) {
var map = mapBrowserEvent.map;
var view2D = map.getView().getView2D();
@@ -124,7 +124,7 @@ ol.interaction.Pan.prototype.handlePointerUp =
/**
* @inheritDoc
*/
ol.interaction.Pan.prototype.handlePointerDown =
ol.interaction.DragPan.prototype.handlePointerDown =
function(mapBrowserEvent) {
if (this.targetPointers.length > 0 && this.condition_(mapBrowserEvent)) {
var map = mapBrowserEvent.map;

View File

@@ -3,14 +3,14 @@ goog.provide('ol.interaction');
goog.require('ol.Collection');
goog.require('ol.Kinetic');
goog.require('ol.interaction.DoubleClickZoom');
goog.require('ol.interaction.DragPan');
goog.require('ol.interaction.DragRotate');
goog.require('ol.interaction.DragZoom');
goog.require('ol.interaction.KeyboardPan');
goog.require('ol.interaction.KeyboardZoom');
goog.require('ol.interaction.MouseWheelZoom');
goog.require('ol.interaction.Pan');
goog.require('ol.interaction.Rotate');
goog.require('ol.interaction.Zoom');
goog.require('ol.interaction.PinchRotate');
goog.require('ol.interaction.PinchZoom');
/**
@@ -50,24 +50,24 @@ ol.interaction.defaults = function(opt_options) {
}));
}
var pan = goog.isDef(options.pan) ?
options.pan : true;
if (pan) {
interactions.push(new ol.interaction.Pan({
var dragPan = goog.isDef(options.dragPan) ?
options.dragPan : true;
if (dragPan) {
interactions.push(new ol.interaction.DragPan({
kinetic: kinetic
}));
}
var rotate = goog.isDef(options.rotate) ?
options.rotate : true;
if (rotate) {
interactions.push(new ol.interaction.Rotate());
var pinchRotate = goog.isDef(options.pinchRotate) ?
options.pinchRotate : true;
if (pinchRotate) {
interactions.push(new ol.interaction.PinchRotate());
}
var zoom = goog.isDef(options.zoom) ?
options.zoom : true;
if (zoom) {
interactions.push(new ol.interaction.Zoom({
var pinchZoom = goog.isDef(options.pinchZoom) ?
options.pinchZoom : true;
if (pinchZoom) {
interactions.push(new ol.interaction.PinchZoom({
duration: options.zoomDuration
}));
}

View File

@@ -1 +0,0 @@
@exportSymbol ol.interaction.Pan

View File

@@ -0,0 +1 @@
@exportSymbol ol.interaction.PinchRotate

View File

@@ -1,6 +1,6 @@
// FIXME works for View2D only
goog.provide('ol.interaction.Rotate');
goog.provide('ol.interaction.PinchRotate');
goog.require('goog.asserts');
goog.require('goog.style');
@@ -21,10 +21,10 @@ ol.interaction.ROTATE_ANIMATION_DURATION = 250;
* on a touch screen.
* @constructor
* @extends {ol.interaction.Pointer}
* @param {olx.interaction.RotateOptions=} opt_options Options.
* @param {olx.interaction.PinchRotateOptions=} opt_options Options.
* @todo stability experimental
*/
ol.interaction.Rotate = function(opt_options) {
ol.interaction.PinchRotate = function(opt_options) {
goog.base(this);
@@ -61,13 +61,13 @@ ol.interaction.Rotate = function(opt_options) {
this.threshold_ = goog.isDef(options.threshold) ? options.threshold : 0.3;
};
goog.inherits(ol.interaction.Rotate, ol.interaction.Pointer);
goog.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer);
/**
* @inheritDoc
*/
ol.interaction.Rotate.prototype.handlePointerDrag =
ol.interaction.PinchRotate.prototype.handlePointerDrag =
function(mapBrowserEvent) {
goog.asserts.assert(this.targetPointers.length >= 2);
var rotationDelta = 0.0;
@@ -118,7 +118,7 @@ ol.interaction.Rotate.prototype.handlePointerDrag =
/**
* @inheritDoc
*/
ol.interaction.Rotate.prototype.handlePointerUp =
ol.interaction.PinchRotate.prototype.handlePointerUp =
function(mapBrowserEvent) {
if (this.targetPointers.length < 2) {
var map = mapBrowserEvent.map;
@@ -140,7 +140,7 @@ ol.interaction.Rotate.prototype.handlePointerUp =
/**
* @inheritDoc
*/
ol.interaction.Rotate.prototype.handlePointerDown =
ol.interaction.PinchRotate.prototype.handlePointerDown =
function(mapBrowserEvent) {
if (this.targetPointers.length >= 2) {
var map = mapBrowserEvent.map;

View File

@@ -0,0 +1 @@
@exportSymbol ol.interaction.PinchZoom

View File

@@ -1,6 +1,6 @@
// FIXME works for View2D only
goog.provide('ol.interaction.Zoom');
goog.provide('ol.interaction.PinchZoom');
goog.require('goog.asserts');
goog.require('goog.style');
@@ -15,10 +15,10 @@ goog.require('ol.interaction.Pointer');
* on a touch screen.
* @constructor
* @extends {ol.interaction.Pointer}
* @param {olx.interaction.ZoomOptions=} opt_options Options.
* @param {olx.interaction.PinchZoomOptions=} opt_options Options.
* @todo stability experimental
*/
ol.interaction.Zoom = function(opt_options) {
ol.interaction.PinchZoom = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
@@ -49,13 +49,13 @@ ol.interaction.Zoom = function(opt_options) {
this.lastScaleDelta_ = 1;
};
goog.inherits(ol.interaction.Zoom, ol.interaction.Pointer);
goog.inherits(ol.interaction.PinchZoom, ol.interaction.Pointer);
/**
* @inheritDoc
*/
ol.interaction.Zoom.prototype.handlePointerDrag =
ol.interaction.PinchZoom.prototype.handlePointerDrag =
function(mapBrowserEvent) {
goog.asserts.assert(this.targetPointers.length >= 2);
var scaleDelta = 1.0;
@@ -100,7 +100,7 @@ ol.interaction.Zoom.prototype.handlePointerDrag =
/**
* @inheritDoc
*/
ol.interaction.Zoom.prototype.handlePointerUp =
ol.interaction.PinchZoom.prototype.handlePointerUp =
function(mapBrowserEvent) {
if (this.targetPointers.length < 2) {
var map = mapBrowserEvent.map;
@@ -123,7 +123,7 @@ ol.interaction.Zoom.prototype.handlePointerUp =
/**
* @inheritDoc
*/
ol.interaction.Zoom.prototype.handlePointerDown =
ol.interaction.PinchZoom.prototype.handlePointerDown =
function(mapBrowserEvent) {
if (this.targetPointers.length >= 2) {
var map = mapBrowserEvent.map;

View File

@@ -1 +0,0 @@
@exportSymbol ol.interaction.Rotate

View File

@@ -1 +0,0 @@
@exportSymbol ol.interaction.Zoom

View File

@@ -144,9 +144,9 @@ describe('ol.Map', function() {
keyboard: false,
mouseWheelZoom: false,
shiftDragZoom: false,
pan: false,
rotate: false,
zoom: false
dragPan: false,
pinchRotate: false,
pinchZoom: false
};
});