Skip to content

Commit

Permalink
removed scale dependency for copyWorldJump
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Jul 25, 2012
1 parent c50aaab commit 3c70e3c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/map/handler/Map.Drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ L.Map.mergeOptions({
inertiaThreshold: L.Browser.touch ? 32 : 14, // ms

// TODO refactor, move to CRS
worldCopyJump: true,
continuousWorld: false
worldCopyJump: true
});

L.Map.Drag = L.Handler.extend({
Expand All @@ -28,7 +27,7 @@ L.Map.Drag = L.Handler.extend({

var options = this._map.options;

if (options.worldCopyJump && !options.continuousWorld) {
if (options.worldCopyJump) {
this._draggable.on('predrag', this._onPreDrag, this);
this._map.on('viewreset', this._onViewReset, this);
}
Expand Down Expand Up @@ -84,15 +83,16 @@ L.Map.Drag = L.Handler.extend({
var pxCenter = this._map.getSize().divideBy(2),
pxWorldCenter = this._map.latLngToLayerPoint(new L.LatLng(0, 0));

this._initialWorldOffset = pxWorldCenter.subtract(pxCenter);
this._initialWorldOffset = pxWorldCenter.subtract(pxCenter).x;
this._worldWidth = this._map.project(new L.LatLng(0, 180)).x;
},

_onPreDrag: function () {
// TODO refactor to be able to adjust map pane position after zoom
var map = this._map,
worldWidth = map.options.crs.scale(map.getZoom()),
worldWidth = this._worldWidth,
halfWidth = Math.round(worldWidth / 2),
dx = this._initialWorldOffset.x,
dx = this._initialWorldOffset,
x = this._draggable._newPos.x,
newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx,
newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx,
Expand Down

0 comments on commit 3c70e3c

Please sign in to comment.