Skip to content

Commit

Permalink
Fix enforcePanLimits. This was coded in a way that compared
Browse files Browse the repository at this point in the history
coordinates across zoom ranges - this fix simply changes
it so that the compare coords are zoomed correctly. This
fixes #114.
  • Loading branch information
tmcw committed Mar 23, 2012
1 parent 00cdb05 commit 34db798
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions modestmaps.js
Expand Up @@ -2777,17 +2777,17 @@ var MM = com.modestmaps = {

enforcePanLimits: function(coord) {

var limits = this.coordLimits;

if (limits) {
if (this.coordLimits) {

coord = coord.copy();

// clamp pan:
var topLeftLimit = limits[0].zoomTo(coord.zoom);
var bottomRightLimit = limits[1].zoomTo(coord.zoom);
var currentTopLeft = this.pointCoordinate(new MM.Point(0,0));
var currentBottomRight = this.pointCoordinate(this.dimensions);
var topLeftLimit = this.coordLimits[0].zoomTo(coord.zoom);
var bottomRightLimit = this.coordLimits[1].zoomTo(coord.zoom);
var currentTopLeft = this.pointCoordinate(new MM.Point(0, 0))
.zoomTo(coord.zoom);
var currentBottomRight = this.pointCoordinate(this.dimensions)
.zoomTo(coord.zoom);

// this handles infinite limits:
// (Infinity - Infinity) is Nan
Expand Down
2 changes: 1 addition & 1 deletion modestmaps.min.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/map.js
Expand Up @@ -526,17 +526,17 @@

enforcePanLimits: function(coord) {

var limits = this.coordLimits;

if (limits) {
if (this.coordLimits) {

coord = coord.copy();

// clamp pan:
var topLeftLimit = limits[0].zoomTo(coord.zoom);
var bottomRightLimit = limits[1].zoomTo(coord.zoom);
var currentTopLeft = this.pointCoordinate(new MM.Point(0,0));
var currentBottomRight = this.pointCoordinate(this.dimensions);
var topLeftLimit = this.coordLimits[0].zoomTo(coord.zoom);
var bottomRightLimit = this.coordLimits[1].zoomTo(coord.zoom);
var currentTopLeft = this.pointCoordinate(new MM.Point(0, 0))
.zoomTo(coord.zoom);
var currentBottomRight = this.pointCoordinate(this.dimensions)
.zoomTo(coord.zoom);

// this handles infinite limits:
// (Infinity - Infinity) is Nan
Expand Down

1 comment on commit 34db798

@shawnbot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks Tom!

Please sign in to comment.