Merge pull request #4372 from Leaflet/prosthetic-callbacks

Switch prosthetic-hand to 1.3.0 and use onStop callback
This commit is contained in:
Yohan Boniface 2016-04-02 17:59:58 +02:00
commit 714cbb9ec6
3 changed files with 61 additions and 55 deletions

View File

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

View File

@ -53,15 +53,9 @@ describe("Map.Drag", function () {
}); });
map.setView([0, 0], 1); map.setView([0, 0], 1);
var hand = new Hand({timing: 'fastframe'}); var hand = new Hand({
var mouse = hand.growFinger('mouse'); timing: 'fastframe',
onStop: function () {
// 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 center = map.getCenter();
var zoom = map.getZoom(); var zoom = map.getZoom();
document.body.removeChild(container); document.body.removeChild(container);
@ -70,7 +64,14 @@ describe("Map.Drag", function () {
expect(zoom).to.be(1); expect(zoom).to.be(1);
done(); done();
}, 100); }
});
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();
}); });
}); });
@ -90,15 +91,9 @@ describe("Map.Drag", function () {
}); });
map.setView([0, 0], 1); map.setView([0, 0], 1);
var hand = new Hand({timing: 'fastframe'}); var hand = new Hand({
var toucher = hand.growFinger('touch'); timing: 'fastframe',
onStop: function () {
// 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 center = map.getCenter();
var zoom = map.getZoom(); var zoom = map.getZoom();
document.body.removeChild(container); document.body.removeChild(container);
@ -107,7 +102,14 @@ describe("Map.Drag", function () {
expect(zoom).to.be(1); expect(zoom).to.be(1);
done(); done();
}, 100); }
});
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();
}); });
}); });

View File

@ -13,12 +13,10 @@ describe("Map.TouchZoom", function () {
}); });
map.setView([0, 0], 1); map.setView([0, 0], 1);
var hand = new Hand({timing: 'fastframe'}); var hand = new Hand({
var f1 = hand.growFinger('touch'); timing: 'fastframe',
var f2 = hand.growFinger('touch'); onStop: function () {
map.once('zoomend', function () {
// L.DomEvent.on(document, 'prostheticHandStop', function () {
setTimeout(function () {
var center = map.getCenter(); var center = map.getCenter();
var zoom = map.getZoom(); var zoom = map.getZoom();
document.body.removeChild(container); document.body.removeChild(container);
@ -29,7 +27,11 @@ describe("Map.TouchZoom", function () {
expect(zoom).to.be(4); expect(zoom).to.be(4);
done(); done();
}, 100); });
}
});
var f1 = hand.growFinger('touch');
var f2 = hand.growFinger('touch');
hand.sync(5); hand.sync(5);
f1.wait(100).moveTo(275, 300, 0) f1.wait(100).moveTo(275, 300, 0)
@ -53,12 +55,10 @@ describe("Map.TouchZoom", function () {
}); });
map.setView([0, 0], 4); map.setView([0, 0], 4);
var hand = new Hand({timing: 'fastframe'}); var hand = new Hand({
var f1 = hand.growFinger('touch'); timing: 'fastframe',
var f2 = hand.growFinger('touch'); onStop: function () {
map.once('zoomend', function () {
// L.DomEvent.on(document, 'prostheticHandStop', function () {
setTimeout(function () {
var center = map.getCenter(); var center = map.getCenter();
var zoom = map.getZoom(); var zoom = map.getZoom();
document.body.removeChild(container); document.body.removeChild(container);
@ -69,7 +69,11 @@ describe("Map.TouchZoom", function () {
expect(zoom).to.be(1); expect(zoom).to.be(1);
done(); done();
}, 100); });
}
});
var f1 = hand.growFinger('touch');
var f2 = hand.growFinger('touch');
hand.sync(5); hand.sync(5);
f1.wait(100).moveTo(75, 300, 0) f1.wait(100).moveTo(75, 300, 0)