Merge pull request #261 from elemoine/zoomfactor
Change default zoom delta and animate mousewheel zoom
This commit is contained in:
@@ -85,28 +85,11 @@ describe('ol.Map', function() {
|
||||
});
|
||||
|
||||
describe('create mousewheel interaction', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
it('creates mousewheel interaction', function() {
|
||||
options.mouseWheelZoom = true;
|
||||
});
|
||||
|
||||
describe('default mouseWheelZoomDelta', function() {
|
||||
it('create mousewheel interaction with default delta', function() {
|
||||
var interactions = ol.Map.createInteractions_(options);
|
||||
expect(interactions.getLength()).toEqual(1);
|
||||
expect(interactions.getAt(0)).toBeA(ol.interaction.MouseWheelZoom);
|
||||
expect(interactions.getAt(0).delta_).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('set mouseWheelZoomDelta', function() {
|
||||
it('create mousewheel interaction with set delta', function() {
|
||||
options.mouseWheelZoomDelta = 7;
|
||||
var interactions = ol.Map.createInteractions_(options);
|
||||
expect(interactions.getLength()).toEqual(1);
|
||||
expect(interactions.getAt(0)).toBeA(ol.interaction.MouseWheelZoom);
|
||||
expect(interactions.getAt(0).delta_).toEqual(7);
|
||||
});
|
||||
var interactions = ol.Map.createInteractions_(options);
|
||||
expect(interactions.getLength()).toEqual(1);
|
||||
expect(interactions.getAt(0)).toBeA(ol.interaction.MouseWheelZoom);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -121,11 +104,11 @@ describe('ol.Map', function() {
|
||||
var interactions = ol.Map.createInteractions_(options);
|
||||
expect(interactions.getLength()).toEqual(1);
|
||||
expect(interactions.getAt(0)).toBeA(ol.interaction.DblClickZoom);
|
||||
expect(interactions.getAt(0).delta_).toEqual(4);
|
||||
expect(interactions.getAt(0).delta_).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('set mouseWheelZoomDelta', function() {
|
||||
describe('set zoomDelta', function() {
|
||||
it('create double click interaction with set delta', function() {
|
||||
options.zoomDelta = 7;
|
||||
var interactions = ol.Map.createInteractions_(options);
|
||||
|
||||
36
test/spec/ol/rotationconstraint.test.js
Normal file
36
test/spec/ol/rotationconstraint.test.js
Normal file
@@ -0,0 +1,36 @@
|
||||
goog.provide('ol.test.RotationConstraint');
|
||||
|
||||
describe('ol.RotationConstraint', function() {
|
||||
|
||||
describe('SnapToZero', function() {
|
||||
|
||||
it('returns expected rotation value', function() {
|
||||
var rotationConstraint = ol.RotationConstraint.createSnapToZero(0.3);
|
||||
|
||||
expect(rotationConstraint(0.1, 0)).toEqual(0);
|
||||
expect(rotationConstraint(0.2, 0)).toEqual(0);
|
||||
expect(rotationConstraint(0.3, 0)).toEqual(0);
|
||||
expect(rotationConstraint(0.4, 0)).toEqual(0.4);
|
||||
|
||||
expect(rotationConstraint(-0.1, 0)).toEqual(0);
|
||||
expect(rotationConstraint(-0.2, 0)).toEqual(0);
|
||||
expect(rotationConstraint(-0.3, 0)).toEqual(0);
|
||||
expect(rotationConstraint(-0.4, 0)).toEqual(-0.4);
|
||||
|
||||
expect(rotationConstraint(1, -0.9)).toEqual(0);
|
||||
expect(rotationConstraint(1, -0.8)).toEqual(0);
|
||||
// floating-point arithmetic
|
||||
expect(rotationConstraint(1, -0.7)).not.toEqual(0);
|
||||
expect(rotationConstraint(1, -0.6)).toEqual(0.4);
|
||||
|
||||
expect(rotationConstraint(-1, 0.9)).toEqual(0);
|
||||
expect(rotationConstraint(-1, 0.8)).toEqual(0);
|
||||
// floating-point arithmetic
|
||||
expect(rotationConstraint(-1, 0.7)).not.toEqual(0);
|
||||
expect(rotationConstraint(-1, 0.6)).toEqual(-0.4);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
goog.require('ol.RotationConstraint');
|
||||
@@ -49,6 +49,16 @@ describe('ol.View2D', function() {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('create rotation constraint', function() {
|
||||
it('gives a correct rotation constraint function', function() {
|
||||
var options = {};
|
||||
var fn = ol.View2D.createConstraints_(options).rotation;
|
||||
expect(fn(0.01, 0)).toEqual(0);
|
||||
expect(fn(0.15, 0)).toEqual(0.15);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user