From c6c0e4f48424bc09469ff1a406b54f1da482bc35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Sat, 2 Apr 2016 17:55:22 +0200 Subject: [PATCH] Switch prosthetic-hand to 1.3.0 and use onStop callback --- package.json | 2 +- spec/suites/map/handler/Map.DragSpec.js | 50 +++++++-------- spec/suites/map/handler/Map.TouchZoomSpec.js | 64 +++++++++++--------- 3 files changed, 61 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index 7475d1e4..6a43b1a1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/spec/suites/map/handler/Map.DragSpec.js b/spec/suites/map/handler/Map.DragSpec.js index d7dbac4b..afa5bad0 100644 --- a/spec/suites/map/handler/Map.DragSpec.js +++ b/spec/suites/map/handler/Map.DragSpec.js @@ -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); }); }); diff --git a/spec/suites/map/handler/Map.TouchZoomSpec.js b/spec/suites/map/handler/Map.TouchZoomSpec.js index 44a05b51..553417f1 100644 --- a/spec/suites/map/handler/Map.TouchZoomSpec.js +++ b/spec/suites/map/handler/Map.TouchZoomSpec.js @@ -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);