Permalink
Browse files

Fix enforcePanLimits. This was coded in a way that compared

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 34db7980dc6ce73b334a63efe4fc82a0f4f39a4b
Showing with 15 additions and 15 deletions.
  1. +7 −7 modestmaps.js
  2. +1 −1 modestmaps.min.js
  3. +7 −7 src/map.js
View
@@ -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
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -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

1 comment on commit 34db798

@shawnbot

This comment has been minimized.

Show comment Hide comment
@shawnbot

shawnbot Mar 23, 2012

Collaborator

Awesome, thanks Tom!

Collaborator

shawnbot commented on 34db798 Mar 23, 2012

Awesome, thanks Tom!

Please sign in to comment.