Transformed
This commit is contained in:
@@ -1,36 +1,34 @@
|
||||
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.events.EventTarget');
|
||||
goog.require('ol.format.GeoJSON');
|
||||
goog.require('ol.interaction.DragAndDrop');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_ from '../../../../src/ol.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_events_Event_ from '../../../../src/ol/events/Event.js';
|
||||
import _ol_events_EventTarget_ from '../../../../src/ol/events/EventTarget.js';
|
||||
import _ol_format_GeoJSON_ from '../../../../src/ol/format/GeoJSON.js';
|
||||
import _ol_interaction_DragAndDrop_ from '../../../../src/ol/interaction/DragAndDrop.js';
|
||||
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
||||
|
||||
where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
var viewport, map, interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
viewport = new ol.events.EventTarget();
|
||||
viewport = new _ol_events_EventTarget_();
|
||||
map = {
|
||||
getViewport: function() {
|
||||
return viewport;
|
||||
},
|
||||
getView: function() {
|
||||
return new ol.View();
|
||||
return new _ol_View_();
|
||||
}
|
||||
};
|
||||
interaction = new ol.interaction.DragAndDrop({
|
||||
formatConstructors: [ol.format.GeoJSON]
|
||||
interaction = new _ol_interaction_DragAndDrop_({
|
||||
formatConstructors: [_ol_format_GeoJSON_]
|
||||
});
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var interaction = new ol.interaction.DragAndDrop();
|
||||
expect(interaction).to.be.an(ol.interaction.DragAndDrop);
|
||||
var interaction = new _ol_interaction_DragAndDrop_();
|
||||
expect(interaction).to.be.an(_ol_interaction_DragAndDrop_);
|
||||
});
|
||||
|
||||
it('sets formatConstructors on the instance', function() {
|
||||
@@ -38,9 +36,9 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
});
|
||||
|
||||
it('accepts a source option', function() {
|
||||
var source = new ol.source.Vector();
|
||||
var drop = new ol.interaction.DragAndDrop({
|
||||
formatConstructors: [ol.format.GeoJSON],
|
||||
var source = new _ol_source_Vector_();
|
||||
var drop = new _ol_interaction_DragAndDrop_({
|
||||
formatConstructors: [_ol_format_GeoJSON_],
|
||||
source: source
|
||||
});
|
||||
expect(drop.source_).to.equal(source);
|
||||
@@ -74,9 +72,9 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
});
|
||||
|
||||
it('registers and unregisters listeners on a custom target', function() {
|
||||
var customTarget = new ol.events.EventTarget();
|
||||
interaction = new ol.interaction.DragAndDrop({
|
||||
formatConstructors: [ol.format.GeoJSON],
|
||||
var customTarget = new _ol_events_EventTarget_();
|
||||
interaction = new _ol_interaction_DragAndDrop_({
|
||||
formatConstructors: [_ol_format_GeoJSON_],
|
||||
target: customTarget
|
||||
});
|
||||
interaction.setMap(map);
|
||||
@@ -97,13 +95,13 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
OrigFileReader = FileReader;
|
||||
|
||||
FileReader = function() {
|
||||
ol.events.EventTarget.apply(this, arguments);
|
||||
_ol_events_EventTarget_.apply(this, arguments);
|
||||
this.readAsText = function(file) {
|
||||
this.result = file;
|
||||
this.dispatchEvent('load');
|
||||
};
|
||||
};
|
||||
ol.inherits(FileReader, ol.events.EventTarget);
|
||||
_ol_.inherits(FileReader, _ol_events_EventTarget_);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -116,7 +114,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
done();
|
||||
});
|
||||
interaction.setMap(map);
|
||||
var event = new ol.events.Event();
|
||||
var event = new _ol_events_Event_();
|
||||
event.dataTransfer = {};
|
||||
event.type = 'dragenter';
|
||||
viewport.dispatchEvent(event);
|
||||
@@ -138,9 +136,9 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
});
|
||||
|
||||
it('adds dropped features to a source', function(done) {
|
||||
var source = new ol.source.Vector();
|
||||
var drop = new ol.interaction.DragAndDrop({
|
||||
formatConstructors: [ol.format.GeoJSON],
|
||||
var source = new _ol_source_Vector_();
|
||||
var drop = new _ol_interaction_DragAndDrop_({
|
||||
formatConstructors: [_ol_format_GeoJSON_],
|
||||
source: source
|
||||
});
|
||||
drop.setMap(map);
|
||||
@@ -151,7 +149,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
var event = new ol.events.Event();
|
||||
var event = new _ol_events_Event_();
|
||||
event.dataTransfer = {};
|
||||
event.type = 'dragenter';
|
||||
viewport.dispatchEvent(event);
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.interaction.DragRotateAndZoom');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_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 _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';
|
||||
|
||||
describe('ol.interaction.DragRotateAndZoom', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.interaction.DragRotateAndZoom();
|
||||
expect(instance).to.be.an(ol.interaction.DragRotateAndZoom);
|
||||
var instance = new _ol_interaction_DragRotateAndZoom_();
|
||||
expect(instance).to.be.an(_ol_interaction_DragRotateAndZoom_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -36,14 +34,14 @@ describe('ol.interaction.DragRotateAndZoom', function() {
|
||||
style.width = width + 'px';
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
var source = new ol.source.Vector();
|
||||
var layer = new ol.layer.Vector({source: source});
|
||||
interaction = new ol.interaction.DragRotateAndZoom();
|
||||
map = new ol.Map({
|
||||
var source = new _ol_source_Vector_();
|
||||
var layer = new _ol_layer_Vector_({source: source});
|
||||
interaction = new _ol_interaction_DragRotateAndZoom_();
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [layer],
|
||||
interactions: [interaction],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -60,26 +58,26 @@ describe('ol.interaction.DragRotateAndZoom', function() {
|
||||
});
|
||||
|
||||
it('does not rotate when rotation is disabled on the view', function() {
|
||||
var event = new ol.MapBrowserPointerEvent('pointermove', map,
|
||||
new ol.pointer.PointerEvent('pointermove', {clientX: 20, clientY: 10}, {pointerType: 'mouse'}),
|
||||
var event = new _ol_MapBrowserPointerEvent_('pointermove', map,
|
||||
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(_ol_interaction_Interaction_, 'rotateWithoutConstraints');
|
||||
interaction.handleDragEvent_(event);
|
||||
expect(spy.callCount).to.be(1);
|
||||
expect(interaction.lastAngle_).to.be(-0.8308214428190254);
|
||||
map.setView(new ol.View({
|
||||
map.setView(new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1,
|
||||
enableRotation: false
|
||||
}));
|
||||
event = new ol.MapBrowserPointerEvent('pointermove', map,
|
||||
new ol.pointer.PointerEvent('pointermove', {clientX: 24, clientY: 16}, {pointerType: 'mouse'}),
|
||||
event = new _ol_MapBrowserPointerEvent_('pointermove', map,
|
||||
new _ol_pointer_PointerEvent_('pointermove', {clientX: 24, clientY: 16}, {pointerType: 'mouse'}),
|
||||
true);
|
||||
interaction.handleDragEvent_(event);
|
||||
expect(spy.callCount).to.be(1);
|
||||
ol.interaction.Interaction.rotateWithoutConstraints.restore();
|
||||
_ol_interaction_Interaction_.rotateWithoutConstraints.restore();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.interaction.DragZoom');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.render.Box');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_extent_ from '../../../../src/ol/extent.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_interaction_DragZoom_ from '../../../../src/ol/interaction/DragZoom.js';
|
||||
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
|
||||
import _ol_render_Box_ from '../../../../src/ol/render/Box.js';
|
||||
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
||||
|
||||
|
||||
describe('ol.interaction.DragZoom', function() {
|
||||
@@ -26,12 +24,12 @@ describe('ol.interaction.DragZoom', function() {
|
||||
style.width = width + 'px';
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
source = new ol.source.Vector();
|
||||
var layer = new ol.layer.Vector({source: source});
|
||||
map = new ol.Map({
|
||||
source = new _ol_source_Vector_();
|
||||
var layer = new _ol_layer_Vector_({source: source});
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [layer],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -50,15 +48,15 @@ describe('ol.interaction.DragZoom', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.interaction.DragZoom();
|
||||
expect(instance).to.be.an(ol.interaction.DragZoom);
|
||||
var instance = new _ol_interaction_DragZoom_();
|
||||
expect(instance).to.be.an(_ol_interaction_DragZoom_);
|
||||
});
|
||||
it('sets "ol-dragzoom" as box className', function() {
|
||||
var instance = new ol.interaction.DragZoom();
|
||||
var instance = new _ol_interaction_DragZoom_();
|
||||
expect(instance.box_.element_.className).to.be('ol-box ol-dragzoom');
|
||||
});
|
||||
it('sets a custom box className', function() {
|
||||
var instance = new ol.interaction.DragZoom({className: 'test-dragzoom'});
|
||||
var instance = new _ol_interaction_DragZoom_({className: 'test-dragzoom'});
|
||||
expect(instance.box_.element_.className).to.be('ol-box test-dragzoom');
|
||||
});
|
||||
|
||||
@@ -67,36 +65,36 @@ describe('ol.interaction.DragZoom', function() {
|
||||
describe('#onBoxEnd()', function() {
|
||||
|
||||
it('centers the view on the box geometry', function(done) {
|
||||
var interaction = new ol.interaction.DragZoom({
|
||||
var interaction = new _ol_interaction_DragZoom_({
|
||||
duration: 10
|
||||
});
|
||||
map.addInteraction(interaction);
|
||||
|
||||
var box = new ol.render.Box();
|
||||
var box = new _ol_render_Box_();
|
||||
var extent = [-110, 40, -90, 60];
|
||||
box.geometry_ = ol.geom.Polygon.fromExtent(extent);
|
||||
box.geometry_ = _ol_geom_Polygon_.fromExtent(extent);
|
||||
interaction.box_ = box;
|
||||
|
||||
interaction.onBoxEnd();
|
||||
setTimeout(function() {
|
||||
var view = map.getView();
|
||||
var center = view.getCenter();
|
||||
expect(center).to.eql(ol.extent.getCenter(extent));
|
||||
expect(center).to.eql(_ol_extent_.getCenter(extent));
|
||||
done();
|
||||
}, 50);
|
||||
|
||||
});
|
||||
|
||||
it('sets new resolution while zooming out', function(done) {
|
||||
var interaction = new ol.interaction.DragZoom({
|
||||
var interaction = new _ol_interaction_DragZoom_({
|
||||
duration: 10,
|
||||
out: true
|
||||
});
|
||||
map.addInteraction(interaction);
|
||||
|
||||
var box = new ol.render.Box();
|
||||
var box = new _ol_render_Box_();
|
||||
var extent = [-11.25, -11.25, 11.25, 11.25];
|
||||
box.geometry_ = ol.geom.Polygon.fromExtent(extent);
|
||||
box.geometry_ = _ol_geom_Polygon_.fromExtent(extent);
|
||||
interaction.box_ = box;
|
||||
|
||||
map.getView().setResolution(0.25);
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.condition');
|
||||
goog.require('ol.geom.Circle');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.MultiLineString');
|
||||
goog.require('ol.geom.MultiPoint');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.interaction.Draw');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_array_ from '../../../../src/ol/array.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import _ol_events_condition_ from '../../../../src/ol/events/condition.js';
|
||||
import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js';
|
||||
import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js';
|
||||
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_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 _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';
|
||||
|
||||
|
||||
describe('ol.interaction.Draw', function() {
|
||||
@@ -36,12 +34,12 @@ describe('ol.interaction.Draw', function() {
|
||||
style.width = width + 'px';
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
source = new ol.source.Vector();
|
||||
var layer = new ol.layer.Vector({source: source});
|
||||
map = new ol.Map({
|
||||
source = new _ol_source_Vector_();
|
||||
var layer = new _ol_layer_Vector_({source: source});
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [layer],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -70,33 +68,33 @@ describe('ol.interaction.Draw', function() {
|
||||
// calculated in case body has top < 0 (test runner with small window)
|
||||
var position = viewport.getBoundingClientRect();
|
||||
var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
|
||||
var event = new ol.pointer.PointerEvent(type, {
|
||||
var event = new _ol_pointer_PointerEvent_(type, {
|
||||
clientX: position.left + x + width / 2,
|
||||
clientY: position.top + y + height / 2,
|
||||
shiftKey: shiftKey
|
||||
});
|
||||
map.handleMapBrowserEvent(new ol.MapBrowserPointerEvent(type, map, event));
|
||||
map.handleMapBrowserEvent(new _ol_MapBrowserPointerEvent_(type, map, event));
|
||||
}
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('creates a new interaction', function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Point'
|
||||
});
|
||||
expect(draw).to.be.a(ol.interaction.Draw);
|
||||
expect(draw).to.be.a(ol.interaction.Interaction);
|
||||
expect(draw).to.be.a(_ol_interaction_Draw_);
|
||||
expect(draw).to.be.a(_ol_interaction_Interaction_);
|
||||
});
|
||||
|
||||
it('accepts a freehand option', function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'LineString',
|
||||
freehand: true
|
||||
});
|
||||
|
||||
var event = new ol.pointer.PointerEvent('pointerdown', {
|
||||
var event = new _ol_pointer_PointerEvent_('pointerdown', {
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
shiftKey: false
|
||||
@@ -110,7 +108,7 @@ describe('ol.interaction.Draw', function() {
|
||||
describe('specifying a geometryName', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
geometryName: 'the_geom',
|
||||
type: 'Point'
|
||||
@@ -125,13 +123,13 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(features[0].getGeometryName()).to.equal('the_geom');
|
||||
expect(geometry).to.be.a(ol.geom.Point);
|
||||
expect(geometry).to.be.a(_ol_geom_Point_);
|
||||
});
|
||||
});
|
||||
|
||||
describe('specifying a clickTolerance', function() {
|
||||
beforeEach(function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Point',
|
||||
clickTolerance: 6
|
||||
@@ -160,7 +158,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var draw;
|
||||
|
||||
beforeEach(function() {
|
||||
draw = new ol.interaction.Draw({
|
||||
draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Point'
|
||||
});
|
||||
@@ -174,7 +172,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Point);
|
||||
expect(geometry).to.be.a(_ol_geom_Point_);
|
||||
expect(geometry.getCoordinates()).to.eql([10, -20]);
|
||||
});
|
||||
|
||||
@@ -198,8 +196,8 @@ describe('ol.interaction.Draw', function() {
|
||||
it('triggers draw events', function() {
|
||||
var ds = sinon.spy();
|
||||
var de = sinon.spy();
|
||||
ol.events.listen(draw, 'drawstart', ds);
|
||||
ol.events.listen(draw, 'drawend', de);
|
||||
_ol_events_.listen(draw, 'drawstart', ds);
|
||||
_ol_events_.listen(draw, 'drawend', de);
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
simulateEvent('pointerdown', 10, 20);
|
||||
simulateEvent('pointerup', 10, 20);
|
||||
@@ -215,7 +213,7 @@ describe('ol.interaction.Draw', function() {
|
||||
end: 0,
|
||||
addfeature: 0
|
||||
};
|
||||
ol.events.listen(draw, 'drawend',
|
||||
_ol_events_.listen(draw, 'drawend',
|
||||
function() {
|
||||
expect(receivedEvents.end).to.be(0);
|
||||
expect(receivedEvents.addfeature).to.be(0);
|
||||
@@ -238,7 +236,7 @@ describe('ol.interaction.Draw', function() {
|
||||
describe('drawing multipoints', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
map.addInteraction(new ol.interaction.Draw({
|
||||
map.addInteraction(new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'MultiPoint'
|
||||
}));
|
||||
@@ -251,7 +249,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.MultiPoint);
|
||||
expect(geometry).to.be.a(_ol_geom_MultiPoint_);
|
||||
expect(geometry.getCoordinates()).to.eql([[30, -15]]);
|
||||
});
|
||||
|
||||
@@ -261,7 +259,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var draw;
|
||||
|
||||
beforeEach(function() {
|
||||
draw = new ol.interaction.Draw({
|
||||
draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'LineString'
|
||||
});
|
||||
@@ -286,7 +284,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.LineString);
|
||||
expect(geometry).to.be.a(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql([[10, -20], [30, -20]]);
|
||||
});
|
||||
|
||||
@@ -328,7 +326,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.LineString);
|
||||
expect(geometry).to.be.a(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql(
|
||||
[[10, -20], [20, -30], [20, -40]]);
|
||||
});
|
||||
@@ -365,7 +363,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
// expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.LineString);
|
||||
expect(geometry).to.be.a(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql(
|
||||
[[10, -20], [20, -30], [30, -40], [40, -50], [50, -60], [60, -70]]);
|
||||
});
|
||||
@@ -394,15 +392,15 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.LineString);
|
||||
expect(geometry).to.be.a(_ol_geom_LineString_);
|
||||
expect(geometry.getCoordinates()).to.eql([[10, -20], [30, -20]]);
|
||||
});
|
||||
|
||||
it('triggers draw events', function() {
|
||||
var ds = sinon.spy();
|
||||
var de = sinon.spy();
|
||||
ol.events.listen(draw, 'drawstart', ds);
|
||||
ol.events.listen(draw, 'drawend', de);
|
||||
_ol_events_.listen(draw, 'drawstart', ds);
|
||||
_ol_events_.listen(draw, 'drawend', de);
|
||||
|
||||
// first point
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
@@ -429,11 +427,11 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
describe('drawing with a finishCondition', function() {
|
||||
beforeEach(function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'LineString',
|
||||
finishCondition: function(event) {
|
||||
if (ol.array.equals(event.coordinate, [30, -20])) {
|
||||
if (_ol_array_.equals(event.coordinate, [30, -20])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -479,7 +477,7 @@ describe('ol.interaction.Draw', function() {
|
||||
describe('drawing multi-linestrings', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
map.addInteraction(new ol.interaction.Draw({
|
||||
map.addInteraction(new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'MultiLineString'
|
||||
}));
|
||||
@@ -503,7 +501,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.MultiLineString);
|
||||
expect(geometry).to.be.a(_ol_geom_MultiLineString_);
|
||||
expect(geometry.getCoordinates()).to.eql([[[10, -20], [30, -20]]]);
|
||||
});
|
||||
|
||||
@@ -513,7 +511,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var draw;
|
||||
|
||||
beforeEach(function() {
|
||||
draw = new ol.interaction.Draw({
|
||||
draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Polygon'
|
||||
});
|
||||
@@ -553,7 +551,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
expect(geometry).to.be.a(_ol_geom_Polygon_);
|
||||
|
||||
expect(geometry.getCoordinates()).to.eql([
|
||||
[[10, -20], [30, -20], [40, -10], [10, -20]]
|
||||
@@ -631,7 +629,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
expect(geometry).to.be.a(_ol_geom_Polygon_);
|
||||
|
||||
expect(geometry.getCoordinates()).to.eql([
|
||||
[[10, -20], [30, -20], [40, -10], [10, -20]]
|
||||
@@ -655,7 +653,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
expect(geometry).to.be.a(_ol_geom_Polygon_);
|
||||
|
||||
expect(geometry.getCoordinates()).to.eql([
|
||||
[[10, -20], [30, -20], [40, -10], [10, -20]]
|
||||
@@ -665,8 +663,8 @@ describe('ol.interaction.Draw', function() {
|
||||
it('triggers draw events', function() {
|
||||
var ds = sinon.spy();
|
||||
var de = sinon.spy();
|
||||
ol.events.listen(draw, 'drawstart', ds);
|
||||
ol.events.listen(draw, 'drawend', de);
|
||||
_ol_events_.listen(draw, 'drawstart', ds);
|
||||
_ol_events_.listen(draw, 'drawend', de);
|
||||
|
||||
// first point
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
@@ -699,7 +697,7 @@ describe('ol.interaction.Draw', function() {
|
||||
describe('drawing multi-polygons', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
map.addInteraction(new ol.interaction.Draw({
|
||||
map.addInteraction(new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'MultiPolygon'
|
||||
}));
|
||||
@@ -729,7 +727,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.MultiPolygon);
|
||||
expect(geometry).to.be.a(_ol_geom_MultiPolygon_);
|
||||
var coordinates = geometry.getCoordinates();
|
||||
expect(coordinates).to.have.length(1);
|
||||
|
||||
@@ -761,7 +759,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.MultiPolygon);
|
||||
expect(geometry).to.be.a(_ol_geom_MultiPolygon_);
|
||||
var coordinates = geometry.getCoordinates();
|
||||
expect(coordinates).to.have.length(1);
|
||||
|
||||
@@ -776,7 +774,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var draw;
|
||||
|
||||
beforeEach(function() {
|
||||
draw = new ol.interaction.Draw({
|
||||
draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Circle'
|
||||
});
|
||||
@@ -797,14 +795,14 @@ describe('ol.interaction.Draw', function() {
|
||||
var features = source.getFeatures();
|
||||
expect(features).to.have.length(1);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Circle);
|
||||
expect(geometry).to.be.a(_ol_geom_Circle_);
|
||||
expect(geometry.getCenter()).to.eql([10, -20]);
|
||||
expect(geometry.getRadius()).to.eql(20);
|
||||
});
|
||||
|
||||
it('supports freehand drawing for circles', function() {
|
||||
draw.freehand_ = true;
|
||||
draw.freehandCondition_ = ol.events.condition.always;
|
||||
draw.freehandCondition_ = _ol_events_condition_.always;
|
||||
|
||||
// no feture created when not moved
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
@@ -823,8 +821,8 @@ describe('ol.interaction.Draw', function() {
|
||||
it('triggers draw events', function() {
|
||||
var ds = sinon.spy();
|
||||
var de = sinon.spy();
|
||||
ol.events.listen(draw, 'drawstart', ds);
|
||||
ol.events.listen(draw, 'drawend', de);
|
||||
_ol_events_.listen(draw, 'drawstart', ds);
|
||||
_ol_events_.listen(draw, 'drawend', de);
|
||||
|
||||
// first point
|
||||
simulateEvent('pointermove', 10, 20);
|
||||
@@ -848,7 +846,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Draw({
|
||||
interaction = new _ol_interaction_Draw_({
|
||||
type: 'LineString'
|
||||
});
|
||||
|
||||
@@ -917,7 +915,7 @@ describe('ol.interaction.Draw', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Draw({
|
||||
interaction = new _ol_interaction_Draw_({
|
||||
type: 'LineString'
|
||||
});
|
||||
expect(interaction.getActive()).to.be(true);
|
||||
@@ -970,11 +968,11 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
describe('ol.interaction.Draw.createRegularPolygon', function() {
|
||||
it('creates a regular polygon in Circle mode', function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Circle',
|
||||
geometryFunction:
|
||||
ol.interaction.Draw.createRegularPolygon(4, Math.PI / 4)
|
||||
_ol_interaction_Draw_.createRegularPolygon(4, Math.PI / 4)
|
||||
});
|
||||
map.addInteraction(draw);
|
||||
|
||||
@@ -990,7 +988,7 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
var features = source.getFeatures();
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
expect(geometry).to.be.a(_ol_geom_Polygon_);
|
||||
var coordinates = geometry.getCoordinates();
|
||||
expect(coordinates[0].length).to.eql(5);
|
||||
expect(coordinates[0][0][0]).to.roughlyEqual(20, 1e-9);
|
||||
@@ -1000,10 +998,10 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
describe('ol.interaction.Draw.createBox', function() {
|
||||
it('creates a box-shaped polygon in Circle mode', function() {
|
||||
var draw = new ol.interaction.Draw({
|
||||
var draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'Circle',
|
||||
geometryFunction: ol.interaction.Draw.createBox()
|
||||
geometryFunction: _ol_interaction_Draw_.createBox()
|
||||
});
|
||||
map.addInteraction(draw);
|
||||
|
||||
@@ -1019,7 +1017,7 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
var features = source.getFeatures();
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
expect(geometry).to.be.a(_ol_geom_Polygon_);
|
||||
var coordinates = geometry.getCoordinates();
|
||||
expect(coordinates[0]).to.have.length(5);
|
||||
expect(geometry.getArea()).to.equal(400);
|
||||
@@ -1032,13 +1030,13 @@ describe('ol.interaction.Draw', function() {
|
||||
var feature;
|
||||
|
||||
beforeEach(function() {
|
||||
draw = new ol.interaction.Draw({
|
||||
draw = new _ol_interaction_Draw_({
|
||||
source: source,
|
||||
type: 'LineString'
|
||||
});
|
||||
map.addInteraction(draw);
|
||||
feature = new ol.Feature(
|
||||
new ol.geom.LineString([[0, 0], [1, 1], [2, 0]]));
|
||||
feature = new _ol_Feature_(
|
||||
new _ol_geom_LineString_([[0, 0], [1, 1], [2, 0]]));
|
||||
});
|
||||
|
||||
it('sets the initial state', function() {
|
||||
@@ -1050,7 +1048,7 @@ describe('ol.interaction.Draw', function() {
|
||||
|
||||
it('dispatches a drawstart event', function() {
|
||||
var spy = sinon.spy();
|
||||
ol.events.listen(draw, 'drawstart', spy);
|
||||
_ol_events_.listen(draw, 'drawstart', spy);
|
||||
draw.extend(feature);
|
||||
expect(spy.callCount).to.be(1);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.interaction.Extent');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_interaction_Extent_ from '../../../../src/ol/interaction/Extent.js';
|
||||
import _ol_pointer_PointerEvent_ from '../../../../src/ol/pointer/PointerEvent.js';
|
||||
|
||||
describe('ol.interaction.Extent', function() {
|
||||
var map, interaction;
|
||||
@@ -15,10 +13,10 @@ describe('ol.interaction.Extent', function() {
|
||||
beforeEach(function() {
|
||||
var target = createMapDiv(width, height);
|
||||
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -26,7 +24,7 @@ describe('ol.interaction.Extent', function() {
|
||||
});
|
||||
map.renderSync();
|
||||
|
||||
interaction = new ol.interaction.Extent();
|
||||
interaction = new _ol_interaction_Extent_();
|
||||
map.addInteraction(interaction);
|
||||
});
|
||||
|
||||
@@ -52,14 +50,14 @@ describe('ol.interaction.Extent', function() {
|
||||
// calculated in case body has top < 0 (test runner with small window)
|
||||
var position = viewport.getBoundingClientRect();
|
||||
var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
|
||||
var pointerEvent = new ol.pointer.PointerEvent(type, {
|
||||
var pointerEvent = new _ol_pointer_PointerEvent_(type, {
|
||||
type: type,
|
||||
button: button,
|
||||
clientX: position.left + x + width / 2,
|
||||
clientY: position.top - y + height / 2,
|
||||
shiftKey: shiftKey
|
||||
});
|
||||
var event = new ol.MapBrowserPointerEvent(type, map, pointerEvent);
|
||||
var event = new _ol_MapBrowserPointerEvent_(type, map, pointerEvent);
|
||||
event.pointerEvent.pointerId = 1;
|
||||
map.handleMapBrowserEvent(event);
|
||||
}
|
||||
@@ -68,7 +66,7 @@ describe('ol.interaction.Extent', function() {
|
||||
|
||||
it('can be configured with an extent', function() {
|
||||
expect(function() {
|
||||
new ol.interaction.Extent({
|
||||
new _ol_interaction_Extent_({
|
||||
extent: [-10, -10, 10, 10]
|
||||
});
|
||||
}).to.not.throwException();
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events.EventTarget');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_events_EventTarget_ from '../../../../src/ol/events/EventTarget.js';
|
||||
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
|
||||
|
||||
describe('ol.interaction.Interaction', function() {
|
||||
|
||||
@@ -11,12 +9,12 @@ describe('ol.interaction.Interaction', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Interaction({});
|
||||
interaction = new _ol_interaction_Interaction_({});
|
||||
});
|
||||
|
||||
it('creates a new interaction', function() {
|
||||
expect(interaction).to.be.a(ol.interaction.Interaction);
|
||||
expect(interaction).to.be.a(ol.events.EventTarget);
|
||||
expect(interaction).to.be.a(_ol_interaction_Interaction_);
|
||||
expect(interaction).to.be.a(_ol_events_EventTarget_);
|
||||
});
|
||||
|
||||
it('creates an active interaction', function() {
|
||||
@@ -28,14 +26,14 @@ describe('ol.interaction.Interaction', function() {
|
||||
describe('#getMap()', function() {
|
||||
|
||||
it('retrieves the associated map', function() {
|
||||
var map = new ol.Map({});
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
var map = new _ol_Map_({});
|
||||
var interaction = new _ol_interaction_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 _ol_interaction_Interaction_({});
|
||||
expect(interaction.getMap()).to.be(null);
|
||||
});
|
||||
|
||||
@@ -44,14 +42,14 @@ describe('ol.interaction.Interaction', function() {
|
||||
describe('#setMap()', function() {
|
||||
|
||||
it('allows a map to be set', function() {
|
||||
var map = new ol.Map({});
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
var map = new _ol_Map_({});
|
||||
var interaction = new _ol_interaction_Interaction_({});
|
||||
interaction.setMap(map);
|
||||
expect(interaction.getMap()).to.be(map);
|
||||
});
|
||||
|
||||
it('accepts null', function() {
|
||||
var interaction = new ol.interaction.Interaction({});
|
||||
var interaction = new _ol_interaction_Interaction_({});
|
||||
interaction.setMap(null);
|
||||
expect(interaction.getMap()).to.be(null);
|
||||
});
|
||||
@@ -61,62 +59,62 @@ describe('ol.interaction.Interaction', function() {
|
||||
describe('zoomByDelta()', function() {
|
||||
|
||||
it('changes view resolution', function() {
|
||||
var view = new ol.View({
|
||||
var view = new _ol_View_({
|
||||
resolution: 1,
|
||||
resolutions: [4, 2, 1, 0.5, 0.25]
|
||||
});
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, 1);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, 1);
|
||||
expect(view.getResolution()).to.be(0.5);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, -1);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, -1);
|
||||
expect(view.getResolution()).to.be(1);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, 2);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, 2);
|
||||
expect(view.getResolution()).to.be(0.25);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, -2);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, -2);
|
||||
expect(view.getResolution()).to.be(1);
|
||||
});
|
||||
|
||||
it('changes view resolution and center relative to the anchor', function() {
|
||||
var view = new ol.View({
|
||||
var view = new _ol_View_({
|
||||
center: [0, 0],
|
||||
resolution: 1,
|
||||
resolutions: [4, 2, 1, 0.5, 0.25]
|
||||
});
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, 1, [10, 10]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, 1, [10, 10]);
|
||||
expect(view.getCenter()).to.eql([5, 5]);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, -1, [0, 0]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, -1, [0, 0]);
|
||||
expect(view.getCenter()).to.eql([10, 10]);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, 2, [0, 0]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, 2, [0, 0]);
|
||||
expect(view.getCenter()).to.eql([2.5, 2.5]);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, -2, [0, 0]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, -2, [0, 0]);
|
||||
expect(view.getCenter()).to.eql([10, 10]);
|
||||
});
|
||||
|
||||
it('changes view resolution and center relative to the anchor, while respecting the extent', function() {
|
||||
var view = new ol.View({
|
||||
var view = new _ol_View_({
|
||||
center: [0, 0],
|
||||
extent: [-2.5, -2.5, 2.5, 2.5],
|
||||
resolution: 1,
|
||||
resolutions: [4, 2, 1, 0.5, 0.25]
|
||||
});
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, 1, [10, 10]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, 1, [10, 10]);
|
||||
expect(view.getCenter()).to.eql([2.5, 2.5]);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, -1, [0, 0]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, -1, [0, 0]);
|
||||
expect(view.getCenter()).to.eql([2.5, 2.5]);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, 2, [10, 10]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, 2, [10, 10]);
|
||||
expect(view.getCenter()).to.eql([2.5, 2.5]);
|
||||
|
||||
ol.interaction.Interaction.zoomByDelta(view, -2, [0, 0]);
|
||||
_ol_interaction_Interaction_.zoomByDelta(view, -2, [0, 0]);
|
||||
expect(view.getCenter()).to.eql([2.5, 2.5]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserEvent_ from '../../../../src/ol/MapBrowserEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_events_Event_ from '../../../../src/ol/events/Event.js';
|
||||
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
|
||||
describe('ol.interaction.KeyboardPan', function() {
|
||||
var map;
|
||||
|
||||
beforeEach(function() {
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: createMapDiv(100, 100),
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
center: [0, 0],
|
||||
resolutions: [1],
|
||||
zoom: 0
|
||||
@@ -25,11 +23,11 @@ describe('ol.interaction.KeyboardPan', function() {
|
||||
|
||||
describe('handleEvent()', function() {
|
||||
it('pans on arrow keys', function() {
|
||||
var spy = sinon.spy(ol.interaction.Interaction, 'pan');
|
||||
var event = new ol.MapBrowserEvent('keydown', map, {
|
||||
var spy = sinon.spy(_ol_interaction_Interaction_, 'pan');
|
||||
var event = new _ol_MapBrowserEvent_('keydown', map, {
|
||||
type: 'keydown',
|
||||
target: map.getTargetElement(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.originalEvent.keyCode = 40; // DOWN
|
||||
map.handleMapBrowserEvent(event);
|
||||
@@ -43,7 +41,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();
|
||||
_ol_interaction_Interaction_.pan.restore();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserEvent_ from '../../../../src/ol/MapBrowserEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_events_Event_ from '../../../../src/ol/events/Event.js';
|
||||
import _ol_interaction_Interaction_ from '../../../../src/ol/interaction/Interaction.js';
|
||||
describe('ol.interaction.KeyboardZoom', function() {
|
||||
var map;
|
||||
|
||||
beforeEach(function() {
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: createMapDiv(100, 100),
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
center: [0, 0],
|
||||
resolutions: [1],
|
||||
zoom: 0
|
||||
@@ -25,11 +23,11 @@ describe('ol.interaction.KeyboardZoom', function() {
|
||||
|
||||
describe('handleEvent()', function() {
|
||||
it('zooms on + and - keys', function() {
|
||||
var spy = sinon.spy(ol.interaction.Interaction, 'zoomByDelta');
|
||||
var event = new ol.MapBrowserEvent('keydown', map, {
|
||||
var spy = sinon.spy(_ol_interaction_Interaction_, 'zoomByDelta');
|
||||
var event = new _ol_MapBrowserEvent_('keydown', map, {
|
||||
type: 'keydown',
|
||||
target: map.getTargetElement(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.originalEvent.charCode = '+'.charCodeAt(0);
|
||||
map.handleMapBrowserEvent(event);
|
||||
@@ -37,7 +35,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();
|
||||
_ol_interaction_Interaction_.zoomByDelta.restore();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
|
||||
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.condition');
|
||||
goog.require('ol.geom.Circle');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.interaction.Modify');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_Collection_ from '../../../../src/ol/Collection.js';
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_events_ from '../../../../src/ol/events.js';
|
||||
import _ol_events_condition_ from '../../../../src/ol/events/condition.js';
|
||||
import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_interaction_Modify_ from '../../../../src/ol/interaction/Modify.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';
|
||||
|
||||
|
||||
describe('ol.interaction.Modify', function() {
|
||||
@@ -36,23 +34,23 @@ describe('ol.interaction.Modify', function() {
|
||||
document.body.appendChild(target);
|
||||
|
||||
features = [
|
||||
new ol.Feature({
|
||||
geometry: new ol.geom.Polygon([
|
||||
new _ol_Feature_({
|
||||
geometry: new _ol_geom_Polygon_([
|
||||
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
|
||||
])
|
||||
})
|
||||
];
|
||||
|
||||
source = new ol.source.Vector({
|
||||
source = new _ol_source_Vector_({
|
||||
features: features
|
||||
});
|
||||
|
||||
var layer = new ol.layer.Vector({source: source});
|
||||
var layer = new _ol_layer_Vector_({source: source});
|
||||
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [layer],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -83,7 +81,7 @@ describe('ol.interaction.Modify', function() {
|
||||
var viewport = map.getViewport();
|
||||
// calculated in case body has top < 0 (test runner with small window)
|
||||
var position = viewport.getBoundingClientRect();
|
||||
var pointerEvent = new ol.pointer.PointerEvent(type, {
|
||||
var pointerEvent = new _ol_pointer_PointerEvent_(type, {
|
||||
type: type,
|
||||
clientX: position.left + x + width / 2,
|
||||
clientY: position.top + y + height / 2,
|
||||
@@ -93,7 +91,7 @@ describe('ol.interaction.Modify', function() {
|
||||
button: button,
|
||||
isPrimary: true
|
||||
});
|
||||
var event = new ol.MapBrowserPointerEvent(type, map, pointerEvent);
|
||||
var event = new _ol_MapBrowserPointerEvent_(type, map, pointerEvent);
|
||||
event.pointerEvent.pointerId = 1;
|
||||
map.handleMapBrowserEvent(event);
|
||||
}
|
||||
@@ -132,11 +130,11 @@ describe('ol.interaction.Modify', function() {
|
||||
var endevent = events[events.length - 1];
|
||||
|
||||
// first event should be modifystary
|
||||
expect(startevent).to.be.an(ol.interaction.Modify.Event);
|
||||
expect(startevent).to.be.an(_ol_interaction_Modify_.Event);
|
||||
expect(startevent.type).to.eql('modifystart');
|
||||
|
||||
// last event should be modifyend
|
||||
expect(endevent).to.be.an(ol.interaction.Modify.Event);
|
||||
expect(endevent).to.be.an(_ol_interaction_Modify_.Event);
|
||||
expect(endevent.type).to.eql('modifyend');
|
||||
|
||||
// make sure we get change events to events array
|
||||
@@ -153,10 +151,10 @@ describe('ol.interaction.Modify', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('adds features to the RTree', function() {
|
||||
var feature = new ol.Feature(
|
||||
new ol.geom.Point([0, 0]));
|
||||
var features = new ol.Collection([feature]);
|
||||
var modify = new ol.interaction.Modify({
|
||||
var feature = new _ol_Feature_(
|
||||
new _ol_geom_Point_([0, 0]));
|
||||
var features = new _ol_Collection_([feature]);
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: features
|
||||
});
|
||||
var rbushEntries = modify.rBush_.getAll();
|
||||
@@ -165,25 +163,25 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
it('accepts feature without geometry', function() {
|
||||
var feature = new ol.Feature();
|
||||
var features = new ol.Collection([feature]);
|
||||
var modify = new ol.interaction.Modify({
|
||||
var feature = new _ol_Feature_();
|
||||
var features = new _ol_Collection_([feature]);
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: features
|
||||
});
|
||||
var rbushEntries = modify.rBush_.getAll();
|
||||
expect(rbushEntries.length).to.be(0);
|
||||
|
||||
feature.setGeometry(new ol.geom.Point([0, 10]));
|
||||
feature.setGeometry(new _ol_geom_Point_([0, 10]));
|
||||
rbushEntries = modify.rBush_.getAll();
|
||||
expect(rbushEntries.length).to.be(1);
|
||||
expect(rbushEntries[0].feature).to.be(feature);
|
||||
});
|
||||
|
||||
it('accepts a source', function() {
|
||||
var feature = new ol.Feature(
|
||||
new ol.geom.Point([0, 0]));
|
||||
var source = new ol.source.Vector({features: [feature]});
|
||||
var modify = new ol.interaction.Modify({source: source});
|
||||
var feature = new _ol_Feature_(
|
||||
new _ol_geom_Point_([0, 0]));
|
||||
var source = new _ol_source_Vector_({features: [feature]});
|
||||
var modify = new _ol_interaction_Modify_({source: source});
|
||||
var rbushEntries = modify.rBush_.getAll();
|
||||
expect(rbushEntries.length).to.be(1);
|
||||
expect(rbushEntries[0].feature).to.be(feature);
|
||||
@@ -201,8 +199,8 @@ describe('ol.interaction.Modify', function() {
|
||||
var second = features[1];
|
||||
var secondRevision = second.getGeometry().getRevision();
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -227,8 +225,8 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
it('deletes first vertex of a LineString', function() {
|
||||
var lineFeature = new ol.Feature({
|
||||
geometry: new ol.geom.LineString(
|
||||
var lineFeature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_LineString_(
|
||||
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
|
||||
)
|
||||
});
|
||||
@@ -239,8 +237,8 @@ describe('ol.interaction.Modify', function() {
|
||||
var first = features[0];
|
||||
var firstRevision = first.getGeometry().getRevision();
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -263,8 +261,8 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
it('deletes last vertex of a LineString', function() {
|
||||
var lineFeature = new ol.Feature({
|
||||
geometry: new ol.geom.LineString(
|
||||
var lineFeature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_LineString_(
|
||||
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
|
||||
)
|
||||
});
|
||||
@@ -275,8 +273,8 @@ describe('ol.interaction.Modify', function() {
|
||||
var first = features[0];
|
||||
var firstRevision = first.getGeometry().getRevision();
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -299,8 +297,8 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
it('deletes vertex of a LineString programmatically', function() {
|
||||
var lineFeature = new ol.Feature({
|
||||
geometry: new ol.geom.LineString(
|
||||
var lineFeature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_LineString_(
|
||||
[[0, 0], [10, 20], [0, 40], [40, 40], [40, 0]]
|
||||
)
|
||||
});
|
||||
@@ -311,8 +309,8 @@ describe('ol.interaction.Modify', function() {
|
||||
var first = features[0];
|
||||
var firstRevision = first.getGeometry().getRevision();
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -341,16 +339,16 @@ describe('ol.interaction.Modify', function() {
|
||||
describe('vertex modification', function() {
|
||||
|
||||
it('keeps the third dimension', function() {
|
||||
var lineFeature = new ol.Feature({
|
||||
geometry: new ol.geom.LineString(
|
||||
var lineFeature = new _ol_Feature_({
|
||||
geometry: new _ol_geom_LineString_(
|
||||
[[0, 0, 10], [10, 20, 20], [0, 40, 30], [40, 40, 40], [40, 0, 50]]
|
||||
)
|
||||
});
|
||||
features.length = 0;
|
||||
features.push(lineFeature);
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -384,12 +382,12 @@ describe('ol.interaction.Modify', function() {
|
||||
|
||||
describe('circle modification', function() {
|
||||
it('changes the circle radius and center', function() {
|
||||
var circleFeature = new ol.Feature(new ol.geom.Circle([10, 10], 20));
|
||||
var circleFeature = new _ol_Feature_(new _ol_geom_Circle_([10, 10], 20));
|
||||
features.length = 0;
|
||||
features.push(circleFeature);
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -419,8 +417,8 @@ describe('ol.interaction.Modify', function() {
|
||||
var modify, feature, events;
|
||||
|
||||
beforeEach(function() {
|
||||
modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -524,9 +522,9 @@ describe('ol.interaction.Modify', function() {
|
||||
var modify, feature, events;
|
||||
|
||||
beforeEach(function() {
|
||||
modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features),
|
||||
deleteCondition: ol.events.condition.doubleClick
|
||||
modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features),
|
||||
deleteCondition: _ol_events_condition_.doubleClick
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -577,8 +575,8 @@ describe('ol.interaction.Modify', function() {
|
||||
return false;
|
||||
});
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features),
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features),
|
||||
insertVertexCondition: listenerSpy
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
@@ -610,7 +608,7 @@ describe('ol.interaction.Modify', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
getListeners = function(feature, modify) {
|
||||
var listeners = ol.events.getListeners(
|
||||
var listeners = _ol_events_.getListeners(
|
||||
feature, 'change');
|
||||
return listeners.filter(function(listener) {
|
||||
return listener.bindTo === modify;
|
||||
@@ -619,12 +617,12 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
it('updates circle segment data', function() {
|
||||
var feature = new ol.Feature(new ol.geom.Circle([10, 10], 20));
|
||||
var feature = new _ol_Feature_(new _ol_geom_Circle_([10, 10], 20));
|
||||
features.length = 0;
|
||||
features.push(feature);
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -659,8 +657,8 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
|
||||
it('updates polygon segment data', function() {
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
|
||||
@@ -699,8 +697,8 @@ describe('ol.interaction.Modify', function() {
|
||||
|
||||
describe('#setActive', function() {
|
||||
it('removes the vertexFeature of deactivation', function() {
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features)
|
||||
var modify = new _ol_interaction_Modify_({
|
||||
features: new _ol_Collection_(features)
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
expect(modify.vertexFeature_).to.be(null);
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.events.Event');
|
||||
goog.require('ol.has');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.interaction.MouseWheelZoom');
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserEvent_ from '../../../../src/ol/MapBrowserEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_events_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 _ol_interaction_MouseWheelZoom_ from '../../../../src/ol/interaction/MouseWheelZoom.js';
|
||||
|
||||
|
||||
describe('ol.interaction.MouseWheelZoom', function() {
|
||||
var map, interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.MouseWheelZoom();
|
||||
map = new ol.Map({
|
||||
interaction = new _ol_interaction_MouseWheelZoom_();
|
||||
map = new _ol_Map_({
|
||||
target: createMapDiv(100, 100),
|
||||
interactions: [interaction],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
center: [0, 0],
|
||||
resolutions: [2, 1, 0.5],
|
||||
zoom: 1
|
||||
@@ -35,27 +33,27 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
||||
describe('timeout duration', function() {
|
||||
var clock;
|
||||
beforeEach(function() {
|
||||
sinon.spy(ol.interaction.Interaction, 'zoomByDelta');
|
||||
sinon.spy(_ol_interaction_Interaction_, 'zoomByDelta');
|
||||
clock = sinon.useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
clock.restore();
|
||||
ol.interaction.Interaction.zoomByDelta.restore();
|
||||
_ol_interaction_Interaction_.zoomByDelta.restore();
|
||||
});
|
||||
|
||||
it('works with the defaut value', function(done) {
|
||||
var event = new ol.MapBrowserEvent('mousewheel', map, {
|
||||
var event = new _ol_MapBrowserEvent_('mousewheel', map, {
|
||||
type: 'mousewheel',
|
||||
target: map.getViewport(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
map.handleMapBrowserEvent(event);
|
||||
clock.tick(50);
|
||||
// default timeout is 80 ms, not called yet
|
||||
expect(ol.interaction.Interaction.zoomByDelta.called).to.be(false);
|
||||
expect(_ol_interaction_Interaction_.zoomByDelta.called).to.be(false);
|
||||
clock.tick(30);
|
||||
expect(ol.interaction.Interaction.zoomByDelta.called).to.be(true);
|
||||
expect(_ol_interaction_Interaction_.zoomByDelta.called).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -65,38 +63,38 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
||||
describe('handleEvent()', function() {
|
||||
|
||||
it('works on Firefox in DOM_DELTA_PIXEL mode (trackpad)', function(done) {
|
||||
var origHasFirefox = ol.has.FIREFOX;
|
||||
ol.has.FIREFOX = true;
|
||||
var origHasFirefox = _ol_has_.FIREFOX;
|
||||
_ol_has_.FIREFOX = true;
|
||||
map.once('postrender', function() {
|
||||
expect(interaction.mode_).to.be(ol.interaction.MouseWheelZoom.Mode_.TRACKPAD);
|
||||
ol.has.FIREFOX = origHasFirefox;
|
||||
expect(interaction.mode_).to.be(_ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD);
|
||||
_ol_has_.FIREFOX = origHasFirefox;
|
||||
done();
|
||||
});
|
||||
var event = new ol.MapBrowserEvent('wheel', map, {
|
||||
var event = new _ol_MapBrowserEvent_('wheel', map, {
|
||||
type: 'wheel',
|
||||
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
|
||||
deltaY: ol.has.DEVICE_PIXEL_RATIO,
|
||||
deltaY: _ol_has_.DEVICE_PIXEL_RATIO,
|
||||
target: map.getViewport(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
|
||||
it('works in DOM_DELTA_PIXEL mode (trackpad)', function(done) {
|
||||
var origHasFirefox = ol.has.FIREFOX;
|
||||
ol.has.FIREFOX = false;
|
||||
var origHasFirefox = _ol_has_.FIREFOX;
|
||||
_ol_has_.FIREFOX = false;
|
||||
map.once('postrender', function() {
|
||||
expect(interaction.mode_).to.be(ol.interaction.MouseWheelZoom.Mode_.TRACKPAD);
|
||||
ol.has.FIREFOX = origHasFirefox;
|
||||
expect(interaction.mode_).to.be(_ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD);
|
||||
_ol_has_.FIREFOX = origHasFirefox;
|
||||
done();
|
||||
});
|
||||
var event = new ol.MapBrowserEvent('wheel', map, {
|
||||
var event = new _ol_MapBrowserEvent_('wheel', map, {
|
||||
type: 'wheel',
|
||||
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
|
||||
deltaY: 1,
|
||||
target: map.getViewport(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
@@ -104,65 +102,65 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
||||
|
||||
describe('spying on ol.interaction.Interaction.zoomByDelta', function() {
|
||||
beforeEach(function() {
|
||||
sinon.spy(ol.interaction.Interaction, 'zoomByDelta');
|
||||
sinon.spy(_ol_interaction_Interaction_, 'zoomByDelta');
|
||||
});
|
||||
afterEach(function() {
|
||||
ol.interaction.Interaction.zoomByDelta.restore();
|
||||
_ol_interaction_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 = _ol_interaction_Interaction_.zoomByDelta.getCall(0);
|
||||
expect(call.args[1]).to.be(-1);
|
||||
expect(call.args[2]).to.eql([0, 0]);
|
||||
done();
|
||||
});
|
||||
var event = new ol.MapBrowserEvent('wheel', map, {
|
||||
var event = new _ol_MapBrowserEvent_('wheel', map, {
|
||||
type: 'wheel',
|
||||
deltaMode: WheelEvent.DOM_DELTA_LINE,
|
||||
deltaY: 3.714599609375,
|
||||
target: map.getViewport(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
|
||||
it('works on Safari (wheel)', function(done) {
|
||||
var origHasSafari = ol.has.SAFARI;
|
||||
ol.has.SAFARI = true;
|
||||
var origHasSafari = _ol_has_.SAFARI;
|
||||
_ol_has_.SAFARI = true;
|
||||
map.once('postrender', function() {
|
||||
var call = ol.interaction.Interaction.zoomByDelta.getCall(0);
|
||||
var call = _ol_interaction_Interaction_.zoomByDelta.getCall(0);
|
||||
expect(call.args[1]).to.be(-1);
|
||||
expect(call.args[2]).to.eql([0, 0]);
|
||||
ol.has.SAFARI = origHasSafari;
|
||||
_ol_has_.SAFARI = origHasSafari;
|
||||
done();
|
||||
});
|
||||
var event = new ol.MapBrowserEvent('mousewheel', map, {
|
||||
var event = new _ol_MapBrowserEvent_('mousewheel', map, {
|
||||
type: 'mousewheel',
|
||||
wheelDeltaY: -50,
|
||||
target: map.getViewport(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
});
|
||||
|
||||
it('works on other browsers (wheel)', function(done) {
|
||||
var origHasSafari = ol.has.SAFARI;
|
||||
ol.has.SAFARI = false;
|
||||
var origHasSafari = _ol_has_.SAFARI;
|
||||
_ol_has_.SAFARI = false;
|
||||
map.once('postrender', function() {
|
||||
var call = ol.interaction.Interaction.zoomByDelta.getCall(0);
|
||||
var call = _ol_interaction_Interaction_.zoomByDelta.getCall(0);
|
||||
expect(call.args[1]).to.be(-1);
|
||||
expect(call.args[2]).to.eql([0, 0]);
|
||||
ol.has.SAFARI = origHasSafari;
|
||||
_ol_has_.SAFARI = origHasSafari;
|
||||
done();
|
||||
});
|
||||
var event = new ol.MapBrowserEvent('mousewheel', map, {
|
||||
var event = new _ol_MapBrowserEvent_('mousewheel', map, {
|
||||
type: 'mousewheel',
|
||||
wheelDeltaY: -120,
|
||||
target: map.getViewport(),
|
||||
preventDefault: ol.events.Event.prototype.preventDefault
|
||||
preventDefault: _ol_events_Event_.prototype.preventDefault
|
||||
});
|
||||
event.coordinate = [0, 0];
|
||||
map.handleMapBrowserEvent(event);
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
|
||||
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserEventType');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.interaction.Select');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_Collection_ from '../../../../src/ol/Collection.js';
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserEventType_ from '../../../../src/ol/MapBrowserEventType.js';
|
||||
import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
|
||||
import _ol_interaction_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';
|
||||
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
||||
|
||||
|
||||
describe('ol.interaction.Select', function() {
|
||||
@@ -31,40 +29,40 @@ describe('ol.interaction.Select', function() {
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
|
||||
var geometry = new ol.geom.Polygon([[[0, 0], [0, 40], [40, 40], [40, 0]]]);
|
||||
var geometry = new _ol_geom_Polygon_([[[0, 0], [0, 40], [40, 40], [40, 0]]]);
|
||||
|
||||
// Four overlapping features, two features of type "foo" and two features
|
||||
// of type "bar". The rendering order is, from top to bottom, foo -> bar
|
||||
// -> foo -> bar.
|
||||
var features = [];
|
||||
features.push(
|
||||
new ol.Feature({
|
||||
new _ol_Feature_({
|
||||
geometry: geometry,
|
||||
type: 'bar'
|
||||
}),
|
||||
new ol.Feature({
|
||||
new _ol_Feature_({
|
||||
geometry: geometry,
|
||||
type: 'foo'
|
||||
}),
|
||||
new ol.Feature({
|
||||
new _ol_Feature_({
|
||||
geometry: geometry,
|
||||
type: 'bar'
|
||||
}),
|
||||
new ol.Feature({
|
||||
new _ol_Feature_({
|
||||
geometry: geometry,
|
||||
type: 'foo'
|
||||
}));
|
||||
|
||||
source = new ol.source.Vector({
|
||||
source = new _ol_source_Vector_({
|
||||
features: features
|
||||
});
|
||||
|
||||
layer = new ol.layer.Vector({source: source});
|
||||
layer = new _ol_layer_Vector_({source: source});
|
||||
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [layer],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -94,27 +92,27 @@ describe('ol.interaction.Select', function() {
|
||||
// calculated in case body has top < 0 (test runner with small window)
|
||||
var position = viewport.getBoundingClientRect();
|
||||
var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
|
||||
var event = new ol.pointer.PointerEvent(type, {
|
||||
var event = new _ol_pointer_PointerEvent_(type, {
|
||||
clientX: position.left + x + width / 2,
|
||||
clientY: position.top + y + height / 2,
|
||||
shiftKey: shiftKey
|
||||
});
|
||||
map.handleMapBrowserEvent(new ol.MapBrowserPointerEvent(type, map, event));
|
||||
map.handleMapBrowserEvent(new _ol_MapBrowserPointerEvent_(type, map, event));
|
||||
}
|
||||
|
||||
describe('constructor', 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);
|
||||
var select = new _ol_interaction_Select_();
|
||||
expect(select).to.be.a(_ol_interaction_Select_);
|
||||
expect(select).to.be.a(_ol_interaction_Interaction_);
|
||||
});
|
||||
|
||||
describe('user-provided collection', function() {
|
||||
|
||||
it('uses the user-provided collection', function() {
|
||||
var features = new ol.Collection();
|
||||
var select = new ol.interaction.Select({features: features});
|
||||
var features = new _ol_Collection_();
|
||||
var select = new _ol_interaction_Select_({features: features});
|
||||
expect(select.getFeatures()).to.be(features);
|
||||
});
|
||||
|
||||
@@ -126,7 +124,7 @@ describe('ol.interaction.Select', function() {
|
||||
var select;
|
||||
|
||||
beforeEach(function() {
|
||||
select = new ol.interaction.Select();
|
||||
select = new _ol_interaction_Select_();
|
||||
map.addInteraction(select);
|
||||
});
|
||||
|
||||
@@ -150,7 +148,7 @@ describe('ol.interaction.Select', function() {
|
||||
});
|
||||
select.on('select', listenerSpy);
|
||||
|
||||
simulateEvent(ol.MapBrowserEventType.SINGLECLICK, -10, -10);
|
||||
simulateEvent(_ol_MapBrowserEventType_.SINGLECLICK, -10, -10);
|
||||
|
||||
expect(listenerSpy.callCount).to.be(0);
|
||||
|
||||
@@ -164,8 +162,8 @@ describe('ol.interaction.Select', function() {
|
||||
});
|
||||
select.on('select', listenerSpy);
|
||||
|
||||
simulateEvent(ol.MapBrowserEventType.SINGLECLICK, 10, -20);
|
||||
simulateEvent(ol.MapBrowserEventType.SINGLECLICK, 9, -21);
|
||||
simulateEvent(_ol_MapBrowserEventType_.SINGLECLICK, 10, -20);
|
||||
simulateEvent(_ol_MapBrowserEventType_.SINGLECLICK, 9, -21);
|
||||
|
||||
expect(listenerSpy.callCount).to.be(1);
|
||||
|
||||
@@ -192,7 +190,7 @@ describe('ol.interaction.Select', function() {
|
||||
var select;
|
||||
|
||||
beforeEach(function() {
|
||||
select = new ol.interaction.Select({
|
||||
select = new _ol_interaction_Select_({
|
||||
multi: true
|
||||
});
|
||||
map.addInteraction(select);
|
||||
@@ -241,7 +239,7 @@ describe('ol.interaction.Select', function() {
|
||||
var select;
|
||||
|
||||
beforeEach(function() {
|
||||
select = new ol.interaction.Select({
|
||||
select = new _ol_interaction_Select_({
|
||||
multi: true
|
||||
});
|
||||
map.addInteraction(select);
|
||||
@@ -274,7 +272,7 @@ describe('ol.interaction.Select', function() {
|
||||
describe('with multi set to true', function() {
|
||||
|
||||
it('only selects features that pass the filter', function() {
|
||||
var select = new ol.interaction.Select({
|
||||
var select = new _ol_interaction_Select_({
|
||||
multi: true,
|
||||
filter: function(feature, layer) {
|
||||
return feature.get('type') === 'bar';
|
||||
@@ -291,7 +289,7 @@ describe('ol.interaction.Select', function() {
|
||||
|
||||
it('only selects features that pass the filter ' +
|
||||
'using shift single-click', function() {
|
||||
var select = new ol.interaction.Select({
|
||||
var select = new _ol_interaction_Select_({
|
||||
multi: true,
|
||||
filter: function(feature, layer) {
|
||||
return feature.get('type') === 'bar';
|
||||
@@ -311,7 +309,7 @@ describe('ol.interaction.Select', function() {
|
||||
describe('with multi set to false', function() {
|
||||
|
||||
it('only selects the first feature that passes the filter', function() {
|
||||
var select = new ol.interaction.Select({
|
||||
var select = new _ol_interaction_Select_({
|
||||
multi: false,
|
||||
filter: function(feature, layer) {
|
||||
return feature.get('type') === 'bar';
|
||||
@@ -326,7 +324,7 @@ describe('ol.interaction.Select', function() {
|
||||
|
||||
it('only selects the first feature that passes the filter ' +
|
||||
'using shift single-click', function() {
|
||||
var select = new ol.interaction.Select({
|
||||
var select = new _ol_interaction_Select_({
|
||||
multi: false,
|
||||
filter: function(feature, layer) {
|
||||
return feature.get('type') === 'bar';
|
||||
@@ -346,7 +344,7 @@ describe('ol.interaction.Select', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Select();
|
||||
interaction = new _ol_interaction_Select_();
|
||||
map.addInteraction(interaction);
|
||||
});
|
||||
afterEach(function() {
|
||||
@@ -358,8 +356,8 @@ describe('ol.interaction.Select', function() {
|
||||
var feature = e.selected[0];
|
||||
var layer_ = interaction.getLayer(feature);
|
||||
expect(e.selected).to.have.length(1);
|
||||
expect(feature).to.be.a(ol.Feature);
|
||||
expect(layer_).to.be.a(ol.layer.Vector);
|
||||
expect(feature).to.be.a(_ol_Feature_);
|
||||
expect(layer_).to.be.a(_ol_layer_Vector_);
|
||||
expect(layer_).to.equal(layer);
|
||||
});
|
||||
interaction.on('select', listenerSpy);
|
||||
@@ -374,7 +372,7 @@ describe('ol.interaction.Select', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Select();
|
||||
interaction = new _ol_interaction_Select_();
|
||||
|
||||
expect(interaction.getActive()).to.be(true);
|
||||
|
||||
@@ -414,7 +412,7 @@ describe('ol.interaction.Select', function() {
|
||||
var interaction;
|
||||
|
||||
beforeEach(function() {
|
||||
interaction = new ol.interaction.Select();
|
||||
interaction = new _ol_interaction_Select_();
|
||||
expect(interaction.getActive()).to.be(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.geom.Circle');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.interaction.Snap');
|
||||
import _ol_Collection_ from '../../../../src/ol/Collection.js';
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js';
|
||||
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
|
||||
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
|
||||
import _ol_interaction_Snap_ from '../../../../src/ol/interaction/Snap.js';
|
||||
|
||||
|
||||
describe('ol.interaction.Snap', function() {
|
||||
@@ -15,8 +13,8 @@ describe('ol.interaction.Snap', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
var instance = new ol.interaction.Snap();
|
||||
expect(instance).to.be.an(ol.interaction.Snap);
|
||||
var instance = new _ol_interaction_Snap_();
|
||||
expect(instance).to.be.an(_ol_interaction_Snap_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -38,9 +36,9 @@ describe('ol.interaction.Snap', function() {
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
|
||||
map = new ol.Map({
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -58,9 +56,9 @@ describe('ol.interaction.Snap', function() {
|
||||
});
|
||||
|
||||
it('can handle XYZ coordinates', function() {
|
||||
var point = new ol.Feature(new ol.geom.Point([0, 0, 123]));
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([point])
|
||||
var point = new _ol_Feature_(new _ol_geom_Point_([0, 0, 123]));
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([point])
|
||||
});
|
||||
snapInteraction.setMap(map);
|
||||
|
||||
@@ -69,15 +67,15 @@ describe('ol.interaction.Snap', function() {
|
||||
coordinate: [0, 0],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
// check that the coordinate is in XY and not XYZ
|
||||
expect(event.coordinate).to.eql([0, 0]);
|
||||
});
|
||||
|
||||
it('snaps to edges only', function() {
|
||||
var point = new ol.Feature(new ol.geom.LineString([[-10, 0], [10, 0]]));
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([point]),
|
||||
var point = new _ol_Feature_(new _ol_geom_LineString_([[-10, 0], [10, 0]]));
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([point]),
|
||||
pixelTolerance: 5,
|
||||
vertex: false
|
||||
});
|
||||
@@ -88,14 +86,14 @@ describe('ol.interaction.Snap', function() {
|
||||
coordinate: [7, 4],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
expect(event.coordinate).to.eql([7, 0]);
|
||||
});
|
||||
|
||||
it('snaps to vertices only', function() {
|
||||
var point = new ol.Feature(new ol.geom.LineString([[-10, 0], [10, 0]]));
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([point]),
|
||||
var point = new _ol_Feature_(new _ol_geom_LineString_([[-10, 0], [10, 0]]));
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([point]),
|
||||
pixelTolerance: 5,
|
||||
edge: false
|
||||
});
|
||||
@@ -106,14 +104,14 @@ describe('ol.interaction.Snap', function() {
|
||||
coordinate: [7, 4],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
expect(event.coordinate).to.eql([10, 0]);
|
||||
});
|
||||
|
||||
it('snaps to circle', function() {
|
||||
var circle = new ol.Feature(new ol.geom.Circle([0, 0], 10));
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([circle]),
|
||||
var circle = new _ol_Feature_(new _ol_geom_Circle_([0, 0], 10));
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([circle]),
|
||||
pixelTolerance: 5
|
||||
});
|
||||
snapInteraction.setMap(map);
|
||||
@@ -123,36 +121,36 @@ describe('ol.interaction.Snap', function() {
|
||||
coordinate: [5, 5],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
|
||||
expect(event.coordinate[0]).to.roughlyEqual(Math.sin(Math.PI / 4) * 10, 1e-10);
|
||||
expect(event.coordinate[1]).to.roughlyEqual(Math.sin(Math.PI / 4) * 10, 1e-10);
|
||||
});
|
||||
|
||||
it('handle feature without geometry', function() {
|
||||
var feature = new ol.Feature();
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([feature]),
|
||||
var feature = new _ol_Feature_();
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([feature]),
|
||||
pixelTolerance: 5,
|
||||
edge: false
|
||||
});
|
||||
snapInteraction.setMap(map);
|
||||
|
||||
feature.setGeometry(new ol.geom.LineString([[-10, 0], [10, 0]]));
|
||||
feature.setGeometry(new _ol_geom_LineString_([[-10, 0], [10, 0]]));
|
||||
|
||||
var event = {
|
||||
pixel: [7 + width / 2, height / 2 - 4],
|
||||
coordinate: [7, 4],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
expect(event.coordinate).to.eql([10, 0]);
|
||||
});
|
||||
|
||||
it('handle geometry changes', function() {
|
||||
var line = new ol.Feature(new ol.geom.LineString([[-10, 0], [0, 0]]));
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([line]),
|
||||
var line = new _ol_Feature_(new _ol_geom_LineString_([[-10, 0], [0, 0]]));
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([line]),
|
||||
pixelTolerance: 5,
|
||||
edge: false
|
||||
});
|
||||
@@ -165,17 +163,17 @@ describe('ol.interaction.Snap', function() {
|
||||
coordinate: [7, 4],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
expect(event.coordinate).to.eql([10, 0]);
|
||||
});
|
||||
|
||||
it('handle geometry name changes', function() {
|
||||
var line = new ol.Feature({
|
||||
geometry: new ol.geom.LineString([[-10, 0], [0, 0]]),
|
||||
alt_geometry: new ol.geom.LineString([[-10, 0], [10, 0]])
|
||||
var line = new _ol_Feature_({
|
||||
geometry: new _ol_geom_LineString_([[-10, 0], [0, 0]]),
|
||||
alt_geometry: new _ol_geom_LineString_([[-10, 0], [10, 0]])
|
||||
});
|
||||
var snapInteraction = new ol.interaction.Snap({
|
||||
features: new ol.Collection([line]),
|
||||
var snapInteraction = new _ol_interaction_Snap_({
|
||||
features: new _ol_Collection_([line]),
|
||||
pixelTolerance: 5,
|
||||
edge: false
|
||||
});
|
||||
@@ -188,7 +186,7 @@ describe('ol.interaction.Snap', function() {
|
||||
coordinate: [7, 4],
|
||||
map: map
|
||||
};
|
||||
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
|
||||
_ol_interaction_Snap_.handleEvent_.call(snapInteraction, event);
|
||||
expect(event.coordinate).to.eql([10, 0]);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
|
||||
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserPointerEvent');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.interaction.Translate');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
goog.require('ol.source.Vector');
|
||||
import _ol_Collection_ from '../../../../src/ol/Collection.js';
|
||||
import _ol_Feature_ from '../../../../src/ol/Feature.js';
|
||||
import _ol_Map_ from '../../../../src/ol/Map.js';
|
||||
import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||
import _ol_View_ from '../../../../src/ol/View.js';
|
||||
import _ol_geom_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 _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';
|
||||
|
||||
|
||||
describe('ol.interaction.Translate', function() {
|
||||
@@ -28,18 +26,18 @@ describe('ol.interaction.Translate', function() {
|
||||
style.width = width + 'px';
|
||||
style.height = height + 'px';
|
||||
document.body.appendChild(target);
|
||||
source = new ol.source.Vector();
|
||||
features = [new ol.Feature({
|
||||
geometry: new ol.geom.Point([10, -20])
|
||||
}), new ol.Feature({
|
||||
geometry: new ol.geom.Point([20, -30])
|
||||
source = new _ol_source_Vector_();
|
||||
features = [new _ol_Feature_({
|
||||
geometry: new _ol_geom_Point_([10, -20])
|
||||
}), new _ol_Feature_({
|
||||
geometry: new _ol_geom_Point_([20, -30])
|
||||
})];
|
||||
source.addFeatures(features);
|
||||
var layer = new ol.layer.Vector({source: source});
|
||||
map = new ol.Map({
|
||||
var layer = new _ol_layer_Vector_({source: source});
|
||||
map = new _ol_Map_({
|
||||
target: target,
|
||||
layers: [layer],
|
||||
view: new ol.View({
|
||||
view: new _ol_View_({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
@@ -68,8 +66,8 @@ describe('ol.interaction.Translate', function() {
|
||||
// calculated in case body has top < 0 (test runner with small window)
|
||||
var position = viewport.getBoundingClientRect();
|
||||
var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
|
||||
var event = new ol.MapBrowserPointerEvent(type, map,
|
||||
new ol.pointer.PointerEvent(type, {
|
||||
var event = new _ol_MapBrowserPointerEvent_(type, map,
|
||||
new _ol_pointer_PointerEvent_(type, {
|
||||
clientX: position.left + x + width / 2,
|
||||
clientY: position.top + y + height / 2,
|
||||
shiftKey: shiftKey
|
||||
@@ -111,11 +109,11 @@ describe('ol.interaction.Translate', function() {
|
||||
var endevent = events[events.length - 1];
|
||||
|
||||
// first event should be translatestart
|
||||
expect(startevent).to.be.an(ol.interaction.Translate.Event);
|
||||
expect(startevent).to.be.an(_ol_interaction_Translate_.Event);
|
||||
expect(startevent.type).to.eql('translatestart');
|
||||
|
||||
// last event should be translateend
|
||||
expect(endevent).to.be.an(ol.interaction.Translate.Event);
|
||||
expect(endevent).to.be.an(_ol_interaction_Translate_.Event);
|
||||
expect(endevent.type).to.eql('translateend');
|
||||
|
||||
// make sure we get change events to events array
|
||||
@@ -134,11 +132,11 @@ describe('ol.interaction.Translate', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('creates a new interaction', function() {
|
||||
var translate = new ol.interaction.Translate({
|
||||
var translate = new _ol_interaction_Translate_({
|
||||
features: features
|
||||
});
|
||||
expect(translate).to.be.a(ol.interaction.Translate);
|
||||
expect(translate).to.be.a(ol.interaction.Interaction);
|
||||
expect(translate).to.be.a(_ol_interaction_Translate_);
|
||||
expect(translate).to.be.a(_ol_interaction_Interaction_);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -146,7 +144,7 @@ describe('ol.interaction.Translate', function() {
|
||||
describe('setActive', function() {
|
||||
|
||||
it('works when the map is not set', function() {
|
||||
var translate = new ol.interaction.Translate({
|
||||
var translate = new _ol_interaction_Translate_({
|
||||
features: features
|
||||
});
|
||||
expect(translate.getActive()).to.be(true);
|
||||
@@ -160,8 +158,8 @@ describe('ol.interaction.Translate', function() {
|
||||
var translate;
|
||||
|
||||
beforeEach(function() {
|
||||
translate = new ol.interaction.Translate({
|
||||
features: new ol.Collection([features[0]])
|
||||
translate = new _ol_interaction_Translate_({
|
||||
features: new _ol_Collection_([features[0]])
|
||||
});
|
||||
map.addInteraction(translate);
|
||||
});
|
||||
@@ -174,7 +172,7 @@ describe('ol.interaction.Translate', function() {
|
||||
simulateEvent('pointerdrag', 50, -40);
|
||||
simulateEvent('pointerup', 50, -40);
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Point);
|
||||
expect(geometry).to.be.a(_ol_geom_Point_);
|
||||
expect(geometry.getCoordinates()).to.eql([50, 40]);
|
||||
|
||||
validateEvents(events, [features[0]]);
|
||||
@@ -188,7 +186,7 @@ describe('ol.interaction.Translate', function() {
|
||||
simulateEvent('pointerdrag', 50, -40);
|
||||
simulateEvent('pointerup', 50, -40);
|
||||
var geometry = features[1].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Point);
|
||||
expect(geometry).to.be.a(_ol_geom_Point_);
|
||||
expect(geometry.getCoordinates()).to.eql([20, -30]);
|
||||
|
||||
expect(events).to.be.empty();
|
||||
@@ -199,7 +197,7 @@ describe('ol.interaction.Translate', function() {
|
||||
var translate;
|
||||
|
||||
beforeEach(function() {
|
||||
translate = new ol.interaction.Translate();
|
||||
translate = new _ol_interaction_Translate_();
|
||||
map.addInteraction(translate);
|
||||
});
|
||||
|
||||
@@ -221,7 +219,7 @@ describe('ol.interaction.Translate', function() {
|
||||
var element, translate;
|
||||
|
||||
beforeEach(function() {
|
||||
translate = new ol.interaction.Translate();
|
||||
translate = new _ol_interaction_Translate_();
|
||||
map.addInteraction(translate);
|
||||
element = map.getViewport();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user