Leaflet/debug/tests/touch-zoom-bounce.html

156 lines
3.5 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" id="vp" content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width" />
<script>
// Trick Leaflet into believing we have a touchscreen (for Chrome)
if (window.Touch) { window.ontouchstart = function(){} };
</script>
<link rel="stylesheet" href="../../dist/leaflet.css" />
<script src="../leaflet-include.js"></script>
<script src="../../node_modules/prosthetic-hand/dist/prosthetic-hand.js"></script>
<meta charset="utf-8">
<title>Leaflet test for pinch-zoom-without-bounce</title>
<style>
#map {
position:absolute;
top: 50px;
bottom: 0;
left:0;
right:0;
}
body {margin:0; padding: 0}
</style>
</head>
<body>
This is an automated test for <a href='https://github.com/Leaflet/Leaflet/issues/3530'>#3530</a>.
<div>
<button onclick='resetMap()'>reset</button>
<button onclick='pinchAndPanL()' >⌐¬</button>
<button onclick='pinchAndPanV()' ></button>
<button onclick='pinchAndPanII()'>||</button>
</div>
<div id='map'></div>
<script>
var myCenter = new L.LatLng(63.41, 10.41);
var map = new L.Map('map', {
center: myCenter,
zoom: 15,
minZoom: 1,
// maxZoom: 16,
bounceAtZoomLimits: false
});
//In any map, set minZoom and/or maxZoom, plus bounceAtZoomLimits to false.
var positron = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, &copy; <a href="http://cartodb.com/attributions">CartoDB</a>'
}).addTo(map);
var marker = L.marker(myCenter);
map.addLayer(marker);
var marker2 = L.marker( map.containerPointToLatLng([200, 50]) ).addTo(map);
console.log('marker 2 is at: ', map.containerPointToLatLng([200, 50]) );
// map.on('move', function(ev){
// console.log('map move event A ', map._lastCenter, map._zoom, map._pixelOrigin);
// console.log('map move event B ', map.getCenter());
// });
ES6 modules & Rollup (#4989) * WIP ES6 modules & rollup * WIP ES6 modules & rollup 2 * WIP ES6 modules & rollup 3 * WIP ES6 modules Browser * WIP ES6 module fixes * WIP ES6 modules: simpler browser exports * WIP ES6: refactor CRS/Projection modules, CRS obj -> CRS.Base * get rid of unnecessary index.js * WIP ES6 modules, dom events and stuff * Make linter happy, rollup to dist/ * revert to CRS namespace/class for now * WIP rollup: export more stuff * export controls * rollup: export Layer * rollup: export DomEvent * rollup: export more layer types * rollup: export Popup/Tooltip * WIP: ES6-ify marker, icon, domutil, draggable. * ES6-ify gridlayer, tilelayer. * ES6-ify: Tweak imports-exports, code is now runnable!! * ES6-ify: Fix scope in some DomUtils * ES6-ify: Path, fix Popup * ES6-ify: Lint & cleanup * ES6-ify map handlers, more linting * ES6-ify: Icon.Default namespacing * ES6-ify: Renderers, CircleMarker * ES6-ify: Circle, Polyline, LineUtil * ES6-ify: Polygon, Rectangle, LineUtil, PolyUtil, linting * ES6-ify: SVG.VML * ES6-ify: DomEvent.Pointer, DomEvent.DoubleTap * ES6-ify: Linting, make Karma play nice with Rollup * ES6-ify: More work on fixing bits breaking some unit tests. * ES6-ify: rollup the version number, fiddled with build scripts * ES6-ify: Fiddle with test scripts * ES6-ify: cleanup (refs to global L, imports from (DOM)Util), prevent cyclic loop on Map imports * ES6-ify: More cleanup of (DOM)Util/Browser/DomEvent imports * ES6ify: Use rollup's "legacy" option for ES3 (IE8) builds * ES6-ify: Clean up build scripts, fix CONTRIBUTING.md instructions * Typo * ES6-ify: minor fixes and lefovers after rebasing on top of 1.0.2 * ES6-ify: upgrade to rollup 0.38 for proper IE8 builds, fix L.SVG.VML * Make linter happy. * ES6: Fixing typos and sxrew-ups after big rebase * Fix symlink for debugging scripts * ES6: Cleanup old build scripts * ES6-ify: Update build system to include git rev in L.version * ES6-ify: re-enable unit tests replacing L.Path with L.Polyline * Export Path * ES6ify: cleanup old banner file * ES6-ify: whitespace in var declarations * ES6-ify: Export toTransformation as L.transformation * ES6-ify: cleanup L.transform exports * ES6-ify: "import Util" in Transformation and SVG.VML
2017-01-30 18:35:16 +08:00
// var hand = new Hand({timing: 'minimal'});
var hand = new Hand({timing: 'frame'});
var f1 = hand.growFinger('touch');
var f2 = hand.growFinger('touch');
function resetMap() {
map.setView(myCenter, 15);
}
function pinchAndPanL() {
hand.sync(1000);
f1.wait(200).moveTo(150, 300, 0)
.down()
.moveBy( -50, 0, 1500)
// .moveBy( -1, 0, 1500)
.moveBy( -50, 0, 1500)
.moveBy(0, 100, 1500)
.wait(1500)
.up();
f2.wait(200).moveTo(250, 300, 0)
.down()
.moveBy( 50, 0, 1500)
// .moveBy( 1, 0, 1500)
.moveBy( 50, 0, 1500)
.moveBy(0, 100, 1500)
.wait(1500)
.up();
};
function pinchAndPanV() {
hand.sync(1000);
var center =
f1.wait(200).moveTo(175, 100, 0)
.down()
.moveBy(-100, 300, 500)
.wait(2500)
.up();
f2.wait(200).moveTo(225, 100, 0)
.down()
.moveBy( 100, 300, 500)
.wait(2500)
.up();
};
function pinchAndPanII() {
hand.sync(5);
f1.wait(200).moveTo(175, 100, 0)
.down()
.moveBy(0, 300, 5000)
.wait(1500)
.up();
f2.wait(200).moveTo(225, 100, 0)
.down()
.moveBy(0, 300, 5000)
.wait(1500)
.up();
};
map.on('mousedown mouseup zoomend', function(ev){
// console.log('L: ', performance.now(), JSON.stringify(ev.originalEvent));
console.log('L: ', performance.now(), ev.type);
});
// L.DomEvent.on(map._container, 'touchstart touchend touchmove', function(ev){
// console.log('T: ', performance.now(), ev.type, ev.touches.length, ev.changedTouches.length, ev);
// });
// pinchAndPanL();
pinchAndPanV();
// pinchAndPanII();
</script>
</body>
ES6 modules & Rollup (#4989) * WIP ES6 modules & rollup * WIP ES6 modules & rollup 2 * WIP ES6 modules & rollup 3 * WIP ES6 modules Browser * WIP ES6 module fixes * WIP ES6 modules: simpler browser exports * WIP ES6: refactor CRS/Projection modules, CRS obj -> CRS.Base * get rid of unnecessary index.js * WIP ES6 modules, dom events and stuff * Make linter happy, rollup to dist/ * revert to CRS namespace/class for now * WIP rollup: export more stuff * export controls * rollup: export Layer * rollup: export DomEvent * rollup: export more layer types * rollup: export Popup/Tooltip * WIP: ES6-ify marker, icon, domutil, draggable. * ES6-ify gridlayer, tilelayer. * ES6-ify: Tweak imports-exports, code is now runnable!! * ES6-ify: Fix scope in some DomUtils * ES6-ify: Path, fix Popup * ES6-ify: Lint & cleanup * ES6-ify map handlers, more linting * ES6-ify: Icon.Default namespacing * ES6-ify: Renderers, CircleMarker * ES6-ify: Circle, Polyline, LineUtil * ES6-ify: Polygon, Rectangle, LineUtil, PolyUtil, linting * ES6-ify: SVG.VML * ES6-ify: DomEvent.Pointer, DomEvent.DoubleTap * ES6-ify: Linting, make Karma play nice with Rollup * ES6-ify: More work on fixing bits breaking some unit tests. * ES6-ify: rollup the version number, fiddled with build scripts * ES6-ify: Fiddle with test scripts * ES6-ify: cleanup (refs to global L, imports from (DOM)Util), prevent cyclic loop on Map imports * ES6-ify: More cleanup of (DOM)Util/Browser/DomEvent imports * ES6ify: Use rollup's "legacy" option for ES3 (IE8) builds * ES6-ify: Clean up build scripts, fix CONTRIBUTING.md instructions * Typo * ES6-ify: minor fixes and lefovers after rebasing on top of 1.0.2 * ES6-ify: upgrade to rollup 0.38 for proper IE8 builds, fix L.SVG.VML * Make linter happy. * ES6: Fixing typos and sxrew-ups after big rebase * Fix symlink for debugging scripts * ES6: Cleanup old build scripts * ES6-ify: Update build system to include git rev in L.version * ES6-ify: re-enable unit tests replacing L.Path with L.Polyline * Export Path * ES6ify: cleanup old banner file * ES6-ify: whitespace in var declarations * ES6-ify: Export toTransformation as L.transformation * ES6-ify: cleanup L.transform exports * ES6-ify: "import Util" in Transformation and SVG.VML
2017-01-30 18:35:16 +08:00
</html>