Skip to content
This repository has been archived by the owner on Jul 5, 2018. It is now read-only.

Commit

Permalink
tweaks to pinch/zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
bvibber committed May 25, 2012
1 parent 8df2893 commit dda8293
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions assets/www/app.js
Expand Up @@ -77,24 +77,28 @@ function onDeviceReady()
l10n.initLanguages();
if (window.plugins.pinchZoom !== undefined) {
// TODO: only enable this while on the map view?
window.plugins.pinchZoom.addEventListener('pinchzoom', function(event) {
if (event.type == "pinchzoomend") {
// TODO: zoom when we cross thresholds?
(function() {
var origDistance;
window.plugins.pinchZoom.addEventListener('pinchzoom', function(event) {
if (geo.map) {
console.log(JSON.stringify(event));
var ratio = event.distance / event.startDistance;
if (ratio < 0.5) {
// zoom out
console.log("ZOOM OUT");
geo.map.zoomOut();
} else if (ratio > 1.5) {
// zoom in
console.log("ZOOM IN");
geo.map.zoomIn();
if (event.type == "pinchzoomstart") {
origDistance = event.distance;
}
else if (event.type == "pinchzoommove" || event.type == "pinchzoomend") {
var ratio = event.distance / origDistance;
if (ratio < 0.67) {
// Zooming out
origDistance = event.distance;
geo.map.zoomOut();
} else if (ratio > 1.5) {
// Zooming in
origDistance = event.distance;
geo.map.zoomIn();
}
}
}
}
});
});
})();
}
}

Expand Down

0 comments on commit dda8293

Please sign in to comment.