Update TouchZoomEmu with more crazy tests. Useful when debugging touch zoom behaviour

This commit is contained in:
danzel 2013-04-15 11:54:43 +12:00
parent b36d973d14
commit b0c70f96ad

View File

@ -15,8 +15,16 @@
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
<div style="background-color:chartreuse; width: 100px; height:100px; position: absolute; left: 850px; top: 10px" onclick="Hack1()">Hack1Touch</div>
<div style="background-color:coral; width: 100px; height:100px; position: absolute; left: 850px; top: 120px" onclick="Hack2()">Hack2Touch</div>
<div style="background-color:lightblue; width: 100px; height:100px; position: absolute; left: 850px; top: 230px" onclick="Hack3()">Hack3Touch</div>
<div style="background-color:lightpink; width: 100px; height:100px; position: absolute; left: 850px; top: 340px" onclick="Hack4()">Hack4Touch</div>
<div style="background-color:yellow; width: 100px; height:100px; position: absolute; left: 850px; top: 450px" onclick="alert(buffer)">Print Buffer</div>
<script src="route.js"></script>
<script>
//var buffer = "";
//console.log = function (text) {
// buffer += text + "\r\n";
//}
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18}),
map = new L.Map('map', {layers: [cloudmade], center: new L.LatLng(51.505, -0.04), zoom: 13});
@ -28,8 +36,6 @@
new L.LatLng(51.52, -0.03)
]);
polygon.editing.enable();
map.addLayer(polygon);
var polyline = new L.Polyline([
@ -38,8 +44,6 @@
new L.LatLng(51.52, -0.02)
]);
polyline.editing.enable();
map.addLayer(polyline);
polygon.on('edit', function() {
@ -53,39 +57,43 @@
function Hack1() {
_timerAt = 0;
clearInterval(_timer);
_timer = setInterval(Hack1Timer, 1000);
_timer = setInterval(Hack1Timer, 200);
}
function Hack1Timer() {
console.log(_timerAt);
switch (_timerAt) {
case 0:
map.touchZoom._onTouchStart({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 233, pageY: 321 }] });
break;
case 1:
map.touchZoom._onTouchMove({ touches: [{ pageX: 412, pageY: 312 }, { pageX: 236, pageY: 322 }] });
map.touchZoom._onTouchMove({ touches: [{ pageX: 452, pageY: 312 }, { pageX: 236, pageY: 322 }] });
break;
case 2:
map.touchZoom._onTouchMove({ touches: [{ pageX: 423, pageY: 313 }, { pageX: 243, pageY: 321 }] });
break;
case 3:
map.touchZoom._onTouchMove({ touches: [{ pageX: 476, pageY: 326 }, { pageX: 299, pageY: 321 }] });
break;
case 4:
map.touchZoom._onTouchEnd();
break;
case 3:
map.touchZoom._onTouchStart({ touches: [{ pageX: 423, pageY: 313 }, { pageX: 243, pageY: 321 }] });
break;
case 4:
map.touchZoom._onTouchMove({ touches: [{ pageX: 423, pageY: 313 }, { pageX: 243, pageY: 321 }] });
//map.touchZoom._onTouchMove({ touches: [{ pageX: 476, pageY: 326 }, { pageX: 299, pageY: 321 }] });
break;
case 5:
map.touchZoom._onTouchEnd();
break;
case 6:
clearInterval(_timer);
break;
}
_timerAt++;
}
function Hack2() {
map.touchZoom._onTouchStart({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 233, pageY: 321 }] });
map.touchZoom._onTouchMove({ touches: [{ pageX: 476, pageY: 326 }, { pageX: 299, pageY: 321 }] });
//_timerAt = 0;
//clearInterval(_timer);
//_timer = setInterval(Hack2Timer, 100);
_timerAt = 0;
clearInterval(_timer);
_timer = setInterval(Hack2Timer, 100);
}
function Hack2Timer() {
console.log(_timerAt);
switch (_timerAt) {
case 0:
map.touchZoom._onTouchStart({ touches: [{ pageX: 100, pageY: 100 }, { pageX: 50, pageY: 100}] });
@ -117,6 +125,71 @@
}
_timerAt++;
}
function Hack3() {
_timerAt = 0;
clearInterval(_timer);
_timer = setInterval(Hack3Timer, 100);
}
function Hack3Timer() {
console.log(_timerAt);
switch (_timerAt) {
case 0:
map.touchZoom._onTouchStart({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 233, pageY: 321 }] });
break;
case 1:
map.touchZoom._onTouchMove({ touches: [{ pageX: 412, pageY: 312 }, { pageX: 236, pageY: 322 }] });
break;
case 2:
map.touchZoom._onTouchEnd();
break;
case 3:
map.touchZoom._onTouchStart({ touches: [{ pageX: 423, pageY: 313 }, { pageX: 243, pageY: 321 }] });
break;
case 4:
map.touchZoom._onTouchMove({ touches: [{ pageX: 476, pageY: 326 }, { pageX: 299, pageY: 321 }] });
break;
case 5:
map.touchZoom._onTouchEnd();
break;
case 6:
clearInterval(_timer);
break;
}
_timerAt++;
}
function Hack4() {
_timerAt = 0;
clearInterval(_timer);
_timer = setInterval(Hack4Timer, 40);
}
function Hack4Timer() {
console.log(_timerAt);
switch (_timerAt) {
case 0:
map.touchZoom._onTouchStart({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 233, pageY: 321 }] });
break;
case 1:
map.touchZoom._onTouchMove({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 236, pageY: 322 }] });
break;
case 2:
map.touchZoom._onTouchEnd();
break;
case 5:
map.touchZoom._onTouchStart({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 233, pageY: 321 }] });
break;
case 6:
map.touchZoom._onTouchMove({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 233, pageY: 321 }] });
break;
case 7:
map.touchZoom._onTouchEnd();
break;
case 8:
clearInterval(_timer);
break;
}
_timerAt++;
}
</script>
</body>
</html>