Switch prosthetic-hand to 1.3.0 and use onStop callback

This commit is contained in:
Iván Sánchez Ortega 2016-04-02 17:55:22 +02:00
parent 9560b28515
commit c6c0e4f484
3 changed files with 61 additions and 55 deletions

View File

@ -18,7 +18,7 @@
"magic-string": "^0.7.0",
"mocha": "~2.3.0",
"phantomjs-prebuilt": "^2.1.4",
"prosthetic-hand": "^1.2.0",
"prosthetic-hand": "^1.3.0",
"uglify-js": "~2.4.23"
},
"main": "dist/leaflet-src.js",

View File

@ -53,24 +53,25 @@ describe("Map.Drag", function () {
});
map.setView([0, 0], 1);
var hand = new Hand({timing: 'fastframe'});
var hand = new Hand({
timing: 'fastframe',
onStop: function () {
var center = map.getCenter();
var zoom = map.getZoom();
document.body.removeChild(container);
expect(center.lat).to.be.within(21.9430, 21.9431);
expect(center.lng).to.be(-180);
expect(zoom).to.be(1);
done();
}
});
var mouse = hand.growFinger('mouse');
// We move 5 pixels first to overcome the 3-pixel threshold of
// L.Draggable.
mouse.wait(100).moveTo(200, 200, 0)
.down().moveBy(5, 0, 20).moveBy(256, 32, 200).up();
setTimeout(function () {
var center = map.getCenter();
var zoom = map.getZoom();
document.body.removeChild(container);
expect(center.lat).to.be.within(21.9430, 21.9431);
expect(center.lng).to.be(-180);
expect(zoom).to.be(1);
done();
}, 100);
});
});
@ -90,24 +91,25 @@ describe("Map.Drag", function () {
});
map.setView([0, 0], 1);
var hand = new Hand({timing: 'fastframe'});
var hand = new Hand({
timing: 'fastframe',
onStop: function () {
var center = map.getCenter();
var zoom = map.getZoom();
document.body.removeChild(container);
expect(center.lat).to.be.within(21.9430, 21.9431);
expect(center.lng).to.be(-180);
expect(zoom).to.be(1);
done();
}
});
var toucher = hand.growFinger('touch');
// We move 5 pixels first to overcome the 3-pixel threshold of
// L.Draggable.
toucher.wait(100).moveTo(200, 200, 0)
.down().moveBy(5, 0, 20).moveBy(256, 32, 200).up();
setTimeout(function () {
var center = map.getCenter();
var zoom = map.getZoom();
document.body.removeChild(container);
expect(center.lat).to.be.within(21.9430, 21.9431);
expect(center.lng).to.be(-180);
expect(zoom).to.be(1);
done();
}, 100);
});
});

View File

@ -13,24 +13,26 @@ describe("Map.TouchZoom", function () {
});
map.setView([0, 0], 1);
var hand = new Hand({timing: 'fastframe'});
var hand = new Hand({
timing: 'fastframe',
onStop: function () {
map.once('zoomend', function () {
var center = map.getCenter();
var zoom = map.getZoom();
document.body.removeChild(container);
expect(center.lat).to.be(0);
expect(center.lng).to.be(0);
// Initial zoom 1, initial distance 50px, final distance 450px
expect(zoom).to.be(4);
done();
});
}
});
var f1 = hand.growFinger('touch');
var f2 = hand.growFinger('touch');
// L.DomEvent.on(document, 'prostheticHandStop', function () {
setTimeout(function () {
var center = map.getCenter();
var zoom = map.getZoom();
document.body.removeChild(container);
expect(center.lat).to.be(0);
expect(center.lng).to.be(0);
// Initial zoom 1, initial distance 50px, final distance 450px
expect(zoom).to.be(4);
done();
}, 100);
hand.sync(5);
f1.wait(100).moveTo(275, 300, 0)
.down().moveBy(-200, 0, 500).up(100);
@ -53,24 +55,26 @@ describe("Map.TouchZoom", function () {
});
map.setView([0, 0], 4);
var hand = new Hand({timing: 'fastframe'});
var hand = new Hand({
timing: 'fastframe',
onStop: function () {
map.once('zoomend', function () {
var center = map.getCenter();
var zoom = map.getZoom();
document.body.removeChild(container);
expect(center.lat).to.be(0);
expect(center.lng).to.be(0);
// Initial zoom 4, initial distance 450px, final distance 50px
expect(zoom).to.be(1);
done();
});
}
});
var f1 = hand.growFinger('touch');
var f2 = hand.growFinger('touch');
// L.DomEvent.on(document, 'prostheticHandStop', function () {
setTimeout(function () {
var center = map.getCenter();
var zoom = map.getZoom();
document.body.removeChild(container);
expect(center.lat).to.be(0);
expect(center.lng).to.be(0);
// Initial zoom 4, initial distance 450px, final distance 50px
expect(zoom).to.be(1);
done();
}, 100);
hand.sync(5);
f1.wait(100).moveTo(75, 300, 0)
.down().moveBy(200, 0, 500).up(100);