Rename _ol_interaction_Interaction_ to Interaction

This commit is contained in:
Marc Jansen
2017-12-15 10:18:45 +01:00
committed by Tim Schaub
parent aa630c3682
commit 4a1d50730b
21 changed files with 109 additions and 105 deletions

View File

@@ -3,7 +3,7 @@
*/
import {inherits} from '../index.js';
import MapBrowserEventType from '../MapBrowserEventType.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import Interaction from '../interaction/Interaction.js';
/**
* @classdesc
@@ -24,7 +24,7 @@ var _ol_interaction_DoubleClickZoom_ = function(opt_options) {
*/
this.delta_ = options.delta ? options.delta : 1;
_ol_interaction_Interaction_.call(this, {
Interaction.call(this, {
handleEvent: _ol_interaction_DoubleClickZoom_.handleEvent
});
@@ -36,7 +36,7 @@ var _ol_interaction_DoubleClickZoom_ = function(opt_options) {
};
inherits(_ol_interaction_DoubleClickZoom_, _ol_interaction_Interaction_);
inherits(_ol_interaction_DoubleClickZoom_, Interaction);
/**
@@ -55,7 +55,7 @@ _ol_interaction_DoubleClickZoom_.handleEvent = function(mapBrowserEvent) {
var anchor = mapBrowserEvent.coordinate;
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
var view = map.getView();
_ol_interaction_Interaction_.zoomByDelta(
Interaction.zoomByDelta(
view, delta, anchor, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;

View File

@@ -8,7 +8,7 @@ import {TRUE} from '../functions.js';
import _ol_events_ from '../events.js';
import Event from '../events/Event.js';
import EventType from '../events/EventType.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import Interaction from '../interaction/Interaction.js';
import {get as getProjection} from '../proj.js';
/**
@@ -25,7 +25,7 @@ var _ol_interaction_DragAndDrop_ = function(opt_options) {
var options = opt_options ? opt_options : {};
_ol_interaction_Interaction_.call(this, {
Interaction.call(this, {
handleEvent: _ol_interaction_DragAndDrop_.handleEvent
});
@@ -63,7 +63,7 @@ var _ol_interaction_DragAndDrop_ = function(opt_options) {
};
inherits(_ol_interaction_DragAndDrop_, _ol_interaction_Interaction_);
inherits(_ol_interaction_DragAndDrop_, Interaction);
/**
@@ -176,7 +176,7 @@ _ol_interaction_DragAndDrop_.prototype.registerListeners_ = function() {
* @inheritDoc
*/
_ol_interaction_DragAndDrop_.prototype.setActive = function(active) {
_ol_interaction_Interaction_.prototype.setActive.call(this, active);
Interaction.prototype.setActive.call(this, active);
if (active) {
this.registerListeners_();
} else {
@@ -190,7 +190,7 @@ _ol_interaction_DragAndDrop_.prototype.setActive = function(active) {
*/
_ol_interaction_DragAndDrop_.prototype.setMap = function(map) {
this.unregisterListeners_();
_ol_interaction_Interaction_.prototype.setMap.call(this, map);
Interaction.prototype.setMap.call(this, map);
if (this.getActive()) {
this.registerListeners_();
}
@@ -278,4 +278,5 @@ _ol_interaction_DragAndDrop_.Event = function(type, file, opt_features, opt_proj
};
inherits(_ol_interaction_DragAndDrop_.Event, Event);
export default _ol_interaction_DragAndDrop_;

View File

@@ -6,7 +6,7 @@ import _ol_RotationConstraint_ from '../RotationConstraint.js';
import _ol_ViewHint_ from '../ViewHint.js';
import _ol_events_condition_ from '../events/condition.js';
import {FALSE} from '../functions.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import Interaction from '../interaction/Interaction.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
/**
@@ -77,7 +77,7 @@ _ol_interaction_DragRotate_.handleDragEvent_ = function(mapBrowserEvent) {
if (this.lastAngle_ !== undefined) {
var delta = theta - this.lastAngle_;
var rotation = view.getRotation();
_ol_interaction_Interaction_.rotateWithoutConstraints(
Interaction.rotateWithoutConstraints(
view, rotation - delta);
}
this.lastAngle_ = theta;
@@ -99,7 +99,7 @@ _ol_interaction_DragRotate_.handleUpEvent_ = function(mapBrowserEvent) {
var view = map.getView();
view.setHint(_ol_ViewHint_.INTERACTING, -1);
var rotation = view.getRotation();
_ol_interaction_Interaction_.rotate(view, rotation,
Interaction.rotate(view, rotation,
undefined, this.duration_);
return false;
};

View File

@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
import _ol_RotationConstraint_ from '../RotationConstraint.js';
import _ol_ViewHint_ from '../ViewHint.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import Interaction from '../interaction/Interaction.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
/**
@@ -89,13 +89,13 @@ _ol_interaction_DragRotateAndZoom_.handleDragEvent_ = function(mapBrowserEvent)
var view = map.getView();
if (view.getConstraints().rotation !== _ol_RotationConstraint_.disable && this.lastAngle_ !== undefined) {
var angleDelta = theta - this.lastAngle_;
_ol_interaction_Interaction_.rotateWithoutConstraints(
Interaction.rotateWithoutConstraints(
view, view.getRotation() - angleDelta);
}
this.lastAngle_ = theta;
if (this.lastMagnitude_ !== undefined) {
var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude);
_ol_interaction_Interaction_.zoomWithoutConstraints(view, resolution);
Interaction.zoomWithoutConstraints(view, resolution);
}
if (this.lastMagnitude_ !== undefined) {
this.lastScaleDelta_ = this.lastMagnitude_ / magnitude;
@@ -119,8 +119,8 @@ _ol_interaction_DragRotateAndZoom_.handleUpEvent_ = function(mapBrowserEvent) {
var view = map.getView();
view.setHint(_ol_ViewHint_.INTERACTING, -1);
var direction = this.lastScaleDelta_ - 1;
_ol_interaction_Interaction_.rotate(view, view.getRotation());
_ol_interaction_Interaction_.zoom(view, view.getResolution(),
Interaction.rotate(view, view.getRotation());
Interaction.zoom(view, view.getResolution(),
undefined, this.duration_, direction);
this.lastScaleDelta_ = 0;
return false;

View File

@@ -26,7 +26,7 @@ import _ol_math_ from '../math.js';
* @extends {ol.Object}
* @api
*/
var _ol_interaction_Interaction_ = function(options) {
var Interaction = function(options) {
_ol_Object_.call(this);
@@ -45,7 +45,7 @@ var _ol_interaction_Interaction_ = function(options) {
};
inherits(_ol_interaction_Interaction_, _ol_Object_);
inherits(Interaction, _ol_Object_);
/**
@@ -54,7 +54,7 @@ inherits(_ol_interaction_Interaction_, _ol_Object_);
* @observable
* @api
*/
_ol_interaction_Interaction_.prototype.getActive = function() {
Interaction.prototype.getActive = function() {
return (
/** @type {boolean} */ this.get(_ol_interaction_Property_.ACTIVE)
);
@@ -66,7 +66,7 @@ _ol_interaction_Interaction_.prototype.getActive = function() {
* @return {ol.PluggableMap} Map.
* @api
*/
_ol_interaction_Interaction_.prototype.getMap = function() {
Interaction.prototype.getMap = function() {
return this.map_;
};
@@ -77,7 +77,7 @@ _ol_interaction_Interaction_.prototype.getMap = function() {
* @observable
* @api
*/
_ol_interaction_Interaction_.prototype.setActive = function(active) {
Interaction.prototype.setActive = function(active) {
this.set(_ol_interaction_Property_.ACTIVE, active);
};
@@ -88,7 +88,7 @@ _ol_interaction_Interaction_.prototype.setActive = function(active) {
* the map here.
* @param {ol.PluggableMap} map Map.
*/
_ol_interaction_Interaction_.prototype.setMap = function(map) {
Interaction.prototype.setMap = function(map) {
this.map_ = map;
};
@@ -98,7 +98,7 @@ _ol_interaction_Interaction_.prototype.setMap = function(map) {
* @param {ol.Coordinate} delta Delta.
* @param {number=} opt_duration Duration.
*/
_ol_interaction_Interaction_.pan = function(view, delta, opt_duration) {
Interaction.pan = function(view, delta, opt_duration) {
var currentCenter = view.getCenter();
if (currentCenter) {
var center = view.constrainCenter(
@@ -122,9 +122,9 @@ _ol_interaction_Interaction_.pan = function(view, delta, opt_duration) {
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
*/
_ol_interaction_Interaction_.rotate = function(view, rotation, opt_anchor, opt_duration) {
Interaction.rotate = function(view, rotation, opt_anchor, opt_duration) {
rotation = view.constrainRotation(rotation, 0);
_ol_interaction_Interaction_.rotateWithoutConstraints(
Interaction.rotateWithoutConstraints(
view, rotation, opt_anchor, opt_duration);
};
@@ -135,7 +135,7 @@ _ol_interaction_Interaction_.rotate = function(view, rotation, opt_anchor, opt_d
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
*/
_ol_interaction_Interaction_.rotateWithoutConstraints = function(view, rotation, opt_anchor, opt_duration) {
Interaction.rotateWithoutConstraints = function(view, rotation, opt_anchor, opt_duration) {
if (rotation !== undefined) {
var currentRotation = view.getRotation();
var currentCenter = view.getCenter();
@@ -167,9 +167,9 @@ _ol_interaction_Interaction_.rotateWithoutConstraints = function(view, rotation,
* will select the nearest resolution. If not defined 0 is
* assumed.
*/
_ol_interaction_Interaction_.zoom = function(view, resolution, opt_anchor, opt_duration, opt_direction) {
Interaction.zoom = function(view, resolution, opt_anchor, opt_duration, opt_direction) {
resolution = view.constrainResolution(resolution, 0, opt_direction);
_ol_interaction_Interaction_.zoomWithoutConstraints(
Interaction.zoomWithoutConstraints(
view, resolution, opt_anchor, opt_duration);
};
@@ -180,7 +180,7 @@ _ol_interaction_Interaction_.zoom = function(view, resolution, opt_anchor, opt_d
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
*/
_ol_interaction_Interaction_.zoomByDelta = function(view, delta, opt_anchor, opt_duration) {
Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_duration) {
var currentResolution = view.getResolution();
var resolution = view.constrainResolution(currentResolution, delta, 0);
@@ -208,7 +208,7 @@ _ol_interaction_Interaction_.zoomByDelta = function(view, delta, opt_anchor, opt
];
}
_ol_interaction_Interaction_.zoomWithoutConstraints(
Interaction.zoomWithoutConstraints(
view, resolution, opt_anchor, opt_duration);
};
@@ -219,7 +219,7 @@ _ol_interaction_Interaction_.zoomByDelta = function(view, delta, opt_anchor, opt
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
*/
_ol_interaction_Interaction_.zoomWithoutConstraints = function(view, resolution, opt_anchor, opt_duration) {
Interaction.zoomWithoutConstraints = function(view, resolution, opt_anchor, opt_duration) {
if (resolution) {
var currentResolution = view.getResolution();
var currentCenter = view.getCenter();
@@ -240,4 +240,4 @@ _ol_interaction_Interaction_.zoomWithoutConstraints = function(view, resolution,
}
}
};
export default _ol_interaction_Interaction_;
export default Interaction;

View File

@@ -6,7 +6,7 @@ import _ol_coordinate_ from '../coordinate.js';
import EventType from '../events/EventType.js';
import _ol_events_KeyCode_ from '../events/KeyCode.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import Interaction from '../interaction/Interaction.js';
/**
* @classdesc
@@ -27,7 +27,7 @@ import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
*/
var _ol_interaction_KeyboardPan_ = function(opt_options) {
_ol_interaction_Interaction_.call(this, {
Interaction.call(this, {
handleEvent: _ol_interaction_KeyboardPan_.handleEvent
});
@@ -65,7 +65,7 @@ var _ol_interaction_KeyboardPan_ = function(opt_options) {
};
inherits(_ol_interaction_KeyboardPan_, _ol_interaction_Interaction_);
inherits(_ol_interaction_KeyboardPan_, Interaction);
/**
* Handles the {@link ol.MapBrowserEvent map browser event} if it was a
@@ -101,7 +101,7 @@ _ol_interaction_KeyboardPan_.handleEvent = function(mapBrowserEvent) {
}
var delta = [deltaX, deltaY];
_ol_coordinate_.rotate(delta, view.getRotation());
_ol_interaction_Interaction_.pan(view, delta, this.duration_);
Interaction.pan(view, delta, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;
}

View File

@@ -4,7 +4,7 @@
import {inherits} from '../index.js';
import EventType from '../events/EventType.js';
import _ol_events_condition_ from '../events/condition.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import Interaction from '../interaction/Interaction.js';
/**
* @classdesc
@@ -25,7 +25,7 @@ import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
*/
var _ol_interaction_KeyboardZoom_ = function(opt_options) {
_ol_interaction_Interaction_.call(this, {
Interaction.call(this, {
handleEvent: _ol_interaction_KeyboardZoom_.handleEvent
});
@@ -52,7 +52,7 @@ var _ol_interaction_KeyboardZoom_ = function(opt_options) {
};
inherits(_ol_interaction_KeyboardZoom_, _ol_interaction_Interaction_);
inherits(_ol_interaction_KeyboardZoom_, Interaction);
/**
@@ -75,7 +75,7 @@ _ol_interaction_KeyboardZoom_.handleEvent = function(mapBrowserEvent) {
var map = mapBrowserEvent.map;
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
var view = map.getView();
_ol_interaction_Interaction_.zoomByDelta(
Interaction.zoomByDelta(
view, delta, undefined, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;

View File

@@ -6,7 +6,7 @@ import _ol_ViewHint_ from '../ViewHint.js';
import {easeOut} from '../easing.js';
import EventType from '../events/EventType.js';
import _ol_has_ from '../has.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import Interaction from '../interaction/Interaction.js';
import _ol_math_ from '../math.js';
@@ -27,7 +27,7 @@ var MAX_DELTA = 1;
*/
var _ol_interaction_MouseWheelZoom_ = function(opt_options) {
_ol_interaction_Interaction_.call(this, {
Interaction.call(this, {
handleEvent: _ol_interaction_MouseWheelZoom_.handleEvent
});
@@ -115,7 +115,7 @@ var _ol_interaction_MouseWheelZoom_ = function(opt_options) {
};
inherits(_ol_interaction_MouseWheelZoom_, _ol_interaction_Interaction_);
inherits(_ol_interaction_MouseWheelZoom_, Interaction);
/**
@@ -261,7 +261,7 @@ _ol_interaction_MouseWheelZoom_.prototype.handleWheelZoom_ = function(map) {
}
var maxDelta = MAX_DELTA;
var delta = _ol_math_.clamp(this.delta_, -maxDelta, maxDelta);
_ol_interaction_Interaction_.zoomByDelta(view, -delta, this.lastAnchor_,
Interaction.zoomByDelta(view, -delta, this.lastAnchor_,
this.duration_);
this.mode_ = undefined;
this.delta_ = 0;

View File

@@ -4,7 +4,7 @@
import {inherits} from '../index.js';
import _ol_ViewHint_ from '../ViewHint.js';
import {FALSE} from '../functions.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import Interaction from '../interaction/Interaction.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
import _ol_RotationConstraint_ from '../RotationConstraint.js';
@@ -115,7 +115,7 @@ _ol_interaction_PinchRotate_.handleDragEvent_ = function(mapBrowserEvent) {
if (this.rotating_) {
var rotation = view.getRotation();
map.render();
_ol_interaction_Interaction_.rotateWithoutConstraints(view,
Interaction.rotateWithoutConstraints(view,
rotation + rotationDelta, this.anchor_);
}
};
@@ -134,7 +134,7 @@ _ol_interaction_PinchRotate_.handleUpEvent_ = function(mapBrowserEvent) {
view.setHint(_ol_ViewHint_.INTERACTING, -1);
if (this.rotating_) {
var rotation = view.getRotation();
_ol_interaction_Interaction_.rotate(
Interaction.rotate(
view, rotation, this.anchor_, this.duration_);
}
return false;

View File

@@ -4,7 +4,7 @@
import {inherits} from '../index.js';
import _ol_ViewHint_ from '../ViewHint.js';
import {FALSE} from '../functions.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import Interaction from '../interaction/Interaction.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
/**
@@ -111,7 +111,7 @@ _ol_interaction_PinchZoom_.handleDragEvent_ = function(mapBrowserEvent) {
// scale, bypass the resolution constraint
map.render();
_ol_interaction_Interaction_.zoomWithoutConstraints(view, newResolution, this.anchor_);
Interaction.zoomWithoutConstraints(view, newResolution, this.anchor_);
};
@@ -134,7 +134,7 @@ _ol_interaction_PinchZoom_.handleUpEvent_ = function(mapBrowserEvent) {
// direction not to zoom out/in if user was pinching in/out.
// Direction is > 0 if pinching out, and < 0 if pinching in.
var direction = this.lastScaleDelta_ - 1;
_ol_interaction_Interaction_.zoom(view, resolution,
Interaction.zoom(view, resolution,
this.anchor_, this.duration_, direction);
}
return false;

View File

@@ -5,7 +5,7 @@ import {inherits, nullFunction} from '../index.js';
import {FALSE} from '../functions.js';
import MapBrowserEventType from '../MapBrowserEventType.js';
import MapBrowserPointerEvent from '../MapBrowserPointerEvent.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import Interaction from '../interaction/Interaction.js';
import _ol_obj_ from '../obj.js';
/**
@@ -30,7 +30,7 @@ var _ol_interaction_Pointer_ = function(opt_options) {
var handleEvent = options.handleEvent ?
options.handleEvent : _ol_interaction_Pointer_.handleEvent;
_ol_interaction_Interaction_.call(this, {
Interaction.call(this, {
handleEvent: handleEvent
});
@@ -82,7 +82,7 @@ var _ol_interaction_Pointer_ = function(opt_options) {
};
inherits(_ol_interaction_Pointer_, _ol_interaction_Interaction_);
inherits(_ol_interaction_Pointer_, Interaction);
/**
@@ -220,4 +220,5 @@ _ol_interaction_Pointer_.handleEvent = function(mapBrowserEvent) {
_ol_interaction_Pointer_.prototype.shouldStopEvent = function(handled) {
return handled;
};
export default _ol_interaction_Pointer_;

View File

@@ -9,7 +9,7 @@ import Event from '../events/Event.js';
import _ol_events_condition_ from '../events/condition.js';
import {TRUE} from '../functions.js';
import GeometryType from '../geom/GeometryType.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import Interaction from '../interaction/Interaction.js';
import _ol_layer_Vector_ from '../layer/Vector.js';
import _ol_obj_ from '../obj.js';
import _ol_source_Vector_ from '../source/Vector.js';
@@ -35,7 +35,7 @@ import _ol_style_Style_ from '../style/Style.js';
*/
var _ol_interaction_Select_ = function(opt_options) {
_ol_interaction_Interaction_.call(this, {
Interaction.call(this, {
handleEvent: _ol_interaction_Select_.handleEvent
});
@@ -142,7 +142,7 @@ var _ol_interaction_Select_ = function(opt_options) {
};
inherits(_ol_interaction_Select_, _ol_interaction_Interaction_);
inherits(_ol_interaction_Select_, Interaction);
/**
@@ -315,7 +315,7 @@ _ol_interaction_Select_.prototype.setMap = function(map) {
if (currentMap) {
selectedFeatures.forEach(currentMap.unskipFeature, currentMap);
}
_ol_interaction_Interaction_.prototype.setMap.call(this, map);
Interaction.prototype.setMap.call(this, map);
this.featureOverlay_.setMap(map);
if (map) {
selectedFeatures.forEach(map.skipFeature, map);

View File

@@ -2,7 +2,7 @@ import _ol_Map_ from '../../../../src/ol/Map.js';
import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js';
import _ol_View_ from '../../../../src/ol/View.js';
import _ol_interaction_DragRotateAndZoom_ from '../../../../src/ol/interaction/DragRotateAndZoom.js';
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
import Interaction from '../../../../src/ol/interaction/Interaction.js';
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
@@ -62,7 +62,7 @@ describe('ol.interaction.DragRotateAndZoom', function() {
new _ol_pointer_PointerEvent_('pointermove', {clientX: 20, clientY: 10}, {pointerType: 'mouse'}),
true);
interaction.lastAngle_ = Math.PI;
var spy = sinon.spy(_ol_interaction_Interaction_, 'rotateWithoutConstraints');
var spy = sinon.spy(Interaction, 'rotateWithoutConstraints');
interaction.handleDragEvent_(event);
expect(spy.callCount).to.be(1);
expect(interaction.lastAngle_).to.be(-0.8308214428190254);
@@ -77,7 +77,7 @@ describe('ol.interaction.DragRotateAndZoom', function() {
true);
interaction.handleDragEvent_(event);
expect(spy.callCount).to.be(1);
_ol_interaction_Interaction_.rotateWithoutConstraints.restore();
Interaction.rotateWithoutConstraints.restore();
});
});

View File

@@ -13,7 +13,7 @@ import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js';
import Point from '../../../../src/ol/geom/Point.js';
import Polygon from '../../../../src/ol/geom/Polygon.js';
import _ol_interaction_Draw_ from '../../../../src/ol/interaction/Draw.js';
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
import Interaction from '../../../../src/ol/interaction/Interaction.js';
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
@@ -84,7 +84,7 @@ describe('ol.interaction.Draw', function() {
type: 'Point'
});
expect(draw).to.be.a(_ol_interaction_Draw_);
expect(draw).to.be.a(_ol_interaction_Interaction_);
expect(draw).to.be.a(Interaction);
});
it('accepts a freehand option', function() {

View File

@@ -1,7 +1,7 @@
import _ol_Map_ from '../../../../src/ol/Map.js';
import _ol_View_ from '../../../../src/ol/View.js';
import EventTarget from '../../../../src/ol/events/EventTarget.js';
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
import Interaction from '../../../../src/ol/interaction/Interaction.js';
describe('ol.interaction.Interaction', function() {
@@ -9,11 +9,11 @@ describe('ol.interaction.Interaction', function() {
var interaction;
beforeEach(function() {
interaction = new _ol_interaction_Interaction_({});
interaction = new Interaction({});
});
it('creates a new interaction', function() {
expect(interaction).to.be.a(_ol_interaction_Interaction_);
expect(interaction).to.be.a(Interaction);
expect(interaction).to.be.a(EventTarget);
});
@@ -27,13 +27,13 @@ describe('ol.interaction.Interaction', function() {
it('retrieves the associated map', function() {
var map = new _ol_Map_({});
var interaction = new _ol_interaction_Interaction_({});
var interaction = new Interaction({});
interaction.setMap(map);
expect(interaction.getMap()).to.be(map);
});
it('returns null if no map', function() {
var interaction = new _ol_interaction_Interaction_({});
var interaction = new Interaction({});
expect(interaction.getMap()).to.be(null);
});
@@ -43,13 +43,13 @@ describe('ol.interaction.Interaction', function() {
it('allows a map to be set', function() {
var map = new _ol_Map_({});
var interaction = new _ol_interaction_Interaction_({});
var interaction = new Interaction({});
interaction.setMap(map);
expect(interaction.getMap()).to.be(map);
});
it('accepts null', function() {
var interaction = new _ol_interaction_Interaction_({});
var interaction = new Interaction({});
interaction.setMap(null);
expect(interaction.getMap()).to.be(null);
});
@@ -64,16 +64,16 @@ describe('ol.interaction.Interaction', function() {
resolutions: [4, 2, 1, 0.5, 0.25]
});
_ol_interaction_Interaction_.zoomByDelta(view, 1);
Interaction.zoomByDelta(view, 1);
expect(view.getResolution()).to.be(0.5);
_ol_interaction_Interaction_.zoomByDelta(view, -1);
Interaction.zoomByDelta(view, -1);
expect(view.getResolution()).to.be(1);
_ol_interaction_Interaction_.zoomByDelta(view, 2);
Interaction.zoomByDelta(view, 2);
expect(view.getResolution()).to.be(0.25);
_ol_interaction_Interaction_.zoomByDelta(view, -2);
Interaction.zoomByDelta(view, -2);
expect(view.getResolution()).to.be(1);
});
@@ -84,16 +84,16 @@ describe('ol.interaction.Interaction', function() {
resolutions: [4, 2, 1, 0.5, 0.25]
});
_ol_interaction_Interaction_.zoomByDelta(view, 1, [10, 10]);
Interaction.zoomByDelta(view, 1, [10, 10]);
expect(view.getCenter()).to.eql([5, 5]);
_ol_interaction_Interaction_.zoomByDelta(view, -1, [0, 0]);
Interaction.zoomByDelta(view, -1, [0, 0]);
expect(view.getCenter()).to.eql([10, 10]);
_ol_interaction_Interaction_.zoomByDelta(view, 2, [0, 0]);
Interaction.zoomByDelta(view, 2, [0, 0]);
expect(view.getCenter()).to.eql([2.5, 2.5]);
_ol_interaction_Interaction_.zoomByDelta(view, -2, [0, 0]);
Interaction.zoomByDelta(view, -2, [0, 0]);
expect(view.getCenter()).to.eql([10, 10]);
});
@@ -105,16 +105,16 @@ describe('ol.interaction.Interaction', function() {
resolutions: [4, 2, 1, 0.5, 0.25]
});
_ol_interaction_Interaction_.zoomByDelta(view, 1, [10, 10]);
Interaction.zoomByDelta(view, 1, [10, 10]);
expect(view.getCenter()).to.eql([2.5, 2.5]);
_ol_interaction_Interaction_.zoomByDelta(view, -1, [0, 0]);
Interaction.zoomByDelta(view, -1, [0, 0]);
expect(view.getCenter()).to.eql([2.5, 2.5]);
_ol_interaction_Interaction_.zoomByDelta(view, 2, [10, 10]);
Interaction.zoomByDelta(view, 2, [10, 10]);
expect(view.getCenter()).to.eql([2.5, 2.5]);
_ol_interaction_Interaction_.zoomByDelta(view, -2, [0, 0]);
Interaction.zoomByDelta(view, -2, [0, 0]);
expect(view.getCenter()).to.eql([2.5, 2.5]);
});
});

View File

@@ -2,7 +2,8 @@ import _ol_Map_ from '../../../../src/ol/Map.js';
import MapBrowserEvent from '../../../../src/ol/MapBrowserEvent.js';
import _ol_View_ from '../../../../src/ol/View.js';
import Event from '../../../../src/ol/events/Event.js';
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
import Interaction from '../../../../src/ol/interaction/Interaction.js';
describe('ol.interaction.KeyboardPan', function() {
var map;
@@ -23,7 +24,7 @@ describe('ol.interaction.KeyboardPan', function() {
describe('handleEvent()', function() {
it('pans on arrow keys', function() {
var spy = sinon.spy(_ol_interaction_Interaction_, 'pan');
var spy = sinon.spy(Interaction, 'pan');
var event = new MapBrowserEvent('keydown', map, {
type: 'keydown',
target: map.getTargetElement(),
@@ -41,7 +42,7 @@ describe('ol.interaction.KeyboardPan', function() {
expect(spy.getCall(1).args[1]).to.eql([0, 128]);
expect(spy.getCall(2).args[1]).to.eql([-128, 0]);
expect(spy.getCall(3).args[1]).to.eql([128, 0]);
_ol_interaction_Interaction_.pan.restore();
Interaction.pan.restore();
});
});

View File

@@ -2,7 +2,8 @@ import _ol_Map_ from '../../../../src/ol/Map.js';
import MapBrowserEvent from '../../../../src/ol/MapBrowserEvent.js';
import _ol_View_ from '../../../../src/ol/View.js';
import Event from '../../../../src/ol/events/Event.js';
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
import Interaction from '../../../../src/ol/interaction/Interaction.js';
describe('ol.interaction.KeyboardZoom', function() {
var map;
@@ -23,7 +24,7 @@ describe('ol.interaction.KeyboardZoom', function() {
describe('handleEvent()', function() {
it('zooms on + and - keys', function() {
var spy = sinon.spy(_ol_interaction_Interaction_, 'zoomByDelta');
var spy = sinon.spy(Interaction, 'zoomByDelta');
var event = new MapBrowserEvent('keydown', map, {
type: 'keydown',
target: map.getTargetElement(),
@@ -35,7 +36,7 @@ describe('ol.interaction.KeyboardZoom', function() {
map.handleMapBrowserEvent(event);
expect(spy.getCall(0).args[1]).to.eql(1);
expect(spy.getCall(1).args[1]).to.eql(-1);
_ol_interaction_Interaction_.zoomByDelta.restore();
Interaction.zoomByDelta.restore();
});
});

View File

@@ -3,7 +3,7 @@ import MapBrowserEvent from '../../../../src/ol/MapBrowserEvent.js';
import _ol_View_ from '../../../../src/ol/View.js';
import Event from '../../../../src/ol/events/Event.js';
import _ol_has_ from '../../../../src/ol/has.js';
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
import Interaction from '../../../../src/ol/interaction/Interaction.js';
import _ol_interaction_MouseWheelZoom_ from '../../../../src/ol/interaction/MouseWheelZoom.js';
@@ -33,13 +33,13 @@ describe('ol.interaction.MouseWheelZoom', function() {
describe('timeout duration', function() {
var clock;
beforeEach(function() {
sinon.spy(_ol_interaction_Interaction_, 'zoomByDelta');
sinon.spy(Interaction, 'zoomByDelta');
clock = sinon.useFakeTimers();
});
afterEach(function() {
clock.restore();
_ol_interaction_Interaction_.zoomByDelta.restore();
Interaction.zoomByDelta.restore();
});
it('works with the defaut value', function(done) {
@@ -51,9 +51,9 @@ describe('ol.interaction.MouseWheelZoom', function() {
map.handleMapBrowserEvent(event);
clock.tick(50);
// default timeout is 80 ms, not called yet
expect(_ol_interaction_Interaction_.zoomByDelta.called).to.be(false);
expect(Interaction.zoomByDelta.called).to.be(false);
clock.tick(30);
expect(_ol_interaction_Interaction_.zoomByDelta.called).to.be(true);
expect(Interaction.zoomByDelta.called).to.be(true);
done();
});
@@ -102,15 +102,15 @@ describe('ol.interaction.MouseWheelZoom', function() {
describe('spying on ol.interaction.Interaction.zoomByDelta', function() {
beforeEach(function() {
sinon.spy(_ol_interaction_Interaction_, 'zoomByDelta');
sinon.spy(Interaction, 'zoomByDelta');
});
afterEach(function() {
_ol_interaction_Interaction_.zoomByDelta.restore();
Interaction.zoomByDelta.restore();
});
it('works in DOM_DELTA_LINE mode (wheel)', function(done) {
map.once('postrender', function() {
var call = _ol_interaction_Interaction_.zoomByDelta.getCall(0);
var call = Interaction.zoomByDelta.getCall(0);
expect(call.args[1]).to.be(-1);
expect(call.args[2]).to.eql([0, 0]);
done();
@@ -130,7 +130,7 @@ describe('ol.interaction.MouseWheelZoom', function() {
var origHasSafari = _ol_has_.SAFARI;
_ol_has_.SAFARI = true;
map.once('postrender', function() {
var call = _ol_interaction_Interaction_.zoomByDelta.getCall(0);
var call = Interaction.zoomByDelta.getCall(0);
expect(call.args[1]).to.be(-1);
expect(call.args[2]).to.eql([0, 0]);
_ol_has_.SAFARI = origHasSafari;
@@ -150,7 +150,7 @@ describe('ol.interaction.MouseWheelZoom', function() {
var origHasSafari = _ol_has_.SAFARI;
_ol_has_.SAFARI = false;
map.once('postrender', function() {
var call = _ol_interaction_Interaction_.zoomByDelta.getCall(0);
var call = Interaction.zoomByDelta.getCall(0);
expect(call.args[1]).to.be(-1);
expect(call.args[2]).to.eql([0, 0]);
_ol_has_.SAFARI = origHasSafari;

View File

@@ -5,7 +5,7 @@ import MapBrowserEventType from '../../../../src/ol/MapBrowserEventType.js';
import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js';
import _ol_View_ from '../../../../src/ol/View.js';
import Polygon from '../../../../src/ol/geom/Polygon.js';
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
import Interaction from '../../../../src/ol/interaction/Interaction.js';
import _ol_interaction_Select_ from '../../../../src/ol/interaction/Select.js';
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
@@ -105,7 +105,7 @@ describe('ol.interaction.Select', function() {
it('creates a new interaction', function() {
var select = new _ol_interaction_Select_();
expect(select).to.be.a(_ol_interaction_Select_);
expect(select).to.be.a(_ol_interaction_Interaction_);
expect(select).to.be.a(Interaction);
});
describe('user-provided collection', function() {

View File

@@ -5,7 +5,7 @@ import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js
import _ol_View_ from '../../../../src/ol/View.js';
import Point from '../../../../src/ol/geom/Point.js';
import _ol_interaction_Translate_ from '../../../../src/ol/interaction/Translate.js';
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
import Interaction from '../../../../src/ol/interaction/Interaction.js';
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
@@ -136,7 +136,7 @@ describe('ol.interaction.Translate', function() {
features: features
});
expect(translate).to.be.a(_ol_interaction_Translate_);
expect(translate).to.be.a(_ol_interaction_Interaction_);
expect(translate).to.be.a(Interaction);
});
});

View File

@@ -7,7 +7,7 @@ import Point from '../../../src/ol/geom/Point.js';
import _ol_has_ from '../../../src/ol/has.js';
import _ol_interaction_ from '../../../src/ol/interaction.js';
import _ol_interaction_DoubleClickZoom_ from '../../../src/ol/interaction/DoubleClickZoom.js';
import _ol_interaction_Interaction_ from '../../../src/ol/interaction/Interaction.js';
import Interaction from '../../../src/ol/interaction/Interaction.js';
import _ol_interaction_MouseWheelZoom_ from '../../../src/ol/interaction/MouseWheelZoom.js';
import _ol_interaction_PinchZoom_ from '../../../src/ol/interaction/PinchZoom.js';
import _ol_layer_Tile_ from '../../../src/ol/layer/Tile.js';
@@ -77,7 +77,7 @@ describe('ol.Map', function() {
describe('#addInteraction()', function() {
it('adds an interaction to the map', function() {
var map = new _ol_Map_({});
var interaction = new _ol_interaction_Interaction_({});
var interaction = new Interaction({});
var before = map.getInteractions().getLength();
map.addInteraction(interaction);
@@ -90,7 +90,7 @@ describe('ol.Map', function() {
describe('#removeInteraction()', function() {
it('removes an interaction from the map', function() {
var map = new _ol_Map_({});
var interaction = new _ol_interaction_Interaction_({});
var interaction = new Interaction({});
var before = map.getInteractions().getLength();
map.addInteraction(interaction);