Configure ol.interaction.DragRotate with options

This commit is contained in:
Tom Payne
2013-04-22 14:44:53 +02:00
parent ef17d4f3b8
commit 003ac5536e
3 changed files with 13 additions and 5 deletions

View File

@@ -170,6 +170,11 @@
* click. * click.
*/ */
/**
* @typedef {Object} ol.interaction.DragRotateOptions
* @property {ol.interaction.ConditionType|undefined} condition Condition.
*/
/** /**
* Interactions for the map. Default is true for all options. * Interactions for the map. Default is true for all options.
* @typedef {Object} ol.interaction.DefaultsOptions * @typedef {Object} ol.interaction.DefaultsOptions

View File

@@ -6,6 +6,7 @@ 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');
goog.require('ol.interaction.condition');
/** /**
@@ -18,9 +19,11 @@ ol.interaction.DRAGROTATE_ANIMATION_DURATION = 250;
/** /**
* @constructor * @constructor
* @extends {ol.interaction.Drag} * @extends {ol.interaction.Drag}
* @param {ol.interaction.ConditionType} condition Condition. * @param {ol.interaction.DragRotateOptions=} opt_options Options.
*/ */
ol.interaction.DragRotate = function(condition) { ol.interaction.DragRotate = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
goog.base(this); goog.base(this);
@@ -28,7 +31,8 @@ ol.interaction.DragRotate = function(condition) {
* @private * @private
* @type {ol.interaction.ConditionType} * @type {ol.interaction.ConditionType}
*/ */
this.condition_ = condition; this.condition_ = goog.isDef(options.condition) ?
options.condition : ol.interaction.condition.altShiftKeysOnly;
/** /**
* @private * @private

View File

@@ -31,8 +31,7 @@ ol.interaction.defaults = function(opt_options, opt_interactions) {
var altShiftDragRotate = goog.isDef(options.altShiftDragRotate) ? var altShiftDragRotate = goog.isDef(options.altShiftDragRotate) ?
options.altShiftDragRotate : true; options.altShiftDragRotate : true;
if (altShiftDragRotate) { if (altShiftDragRotate) {
interactions.push(new ol.interaction.DragRotate( interactions.push(new ol.interaction.DragRotate());
ol.interaction.condition.altShiftKeysOnly));
} }
var doubleClickZoom = goog.isDef(options.doubleClickZoom) ? var doubleClickZoom = goog.isDef(options.doubleClickZoom) ?