Skip to content

Commit

Permalink
Fix map.setSize API, and start documenting changes in CHANGELOG. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcw committed Dec 7, 2011
1 parent ceae90d commit 34e9613
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Expand Up @@ -8,6 +8,14 @@ Following the semantic versioning recommendation best we can:
minor version, and backwards incompatible API changes increment
the major version." -- http://semver.org/

v1.0.0 (dev)
- `map.setSize` now only accepts an object of the form `{x: 0, y: 0}`
or a `MM.Size` object, and it calls its callback with a
`MM.Size` argument.
- `map.setExtent` no longer rounds zoom levels by default.
- `map.roundZoom` added to the map to allow for the old behavior
of `map.setExtent` if desired.

v0.21.0
- Returns `this` from `map.addCallback()`, `map.removeCallback()`,
and `map.dispatchCallback()`
Expand Down
14 changes: 5 additions & 9 deletions modestmaps.js
Expand Up @@ -2150,16 +2150,12 @@ var MM = com.modestmaps = {
return this;
},


// Resize the map's container `<div>`, redrawing the map and triggering
// `resized` to make sure that the map's presentation is still correct.
setSize: function(dimensionsOrX, orY) {
if (dimensionsOrX.hasOwnProperty('x') && dimensionsOrX.hasOwnProperty('y')) {
this.dimensions = dimensionsOrX;
}
else if (orY !== undefined && !isNaN(orY)) {
this.dimensions = new MM.Point(dimensionsOrX, orY);
}
setSize: function(dimensions) {
// Ensure that, whether a raw object or a Point object is passed,
// this.dimensions will be a Point.
this.dimensions = new MM.Point(dimensions.x, dimensions.y);
this.parent.style.width = Math.round(this.dimensions.x) + 'px';
this.parent.style.height = Math.round(this.dimensions.y) + 'px';
if (this.autoSize) {
Expand All @@ -2168,7 +2164,7 @@ var MM = com.modestmaps = {
}
this.draw(); // draw calls enforceLimits
// (if you switch to getFrame, call enforceLimits first)
this.dispatchCallback('resized', [this.dimensions]);
this.dispatchCallback('resized', this.dimensions);
return this;
},

Expand Down
2 changes: 1 addition & 1 deletion modestmaps.min.js

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions src/map.js
Expand Up @@ -289,16 +289,12 @@
return this;
},


// Resize the map's container `<div>`, redrawing the map and triggering
// `resized` to make sure that the map's presentation is still correct.
setSize: function(dimensionsOrX, orY) {
if (dimensionsOrX.hasOwnProperty('x') && dimensionsOrX.hasOwnProperty('y')) {
this.dimensions = dimensionsOrX;
}
else if (orY !== undefined && !isNaN(orY)) {
this.dimensions = new MM.Point(dimensionsOrX, orY);
}
setSize: function(dimensions) {
// Ensure that, whether a raw object or a Point object is passed,
// this.dimensions will be a Point.
this.dimensions = new MM.Point(dimensions.x, dimensions.y);
this.parent.style.width = Math.round(this.dimensions.x) + 'px';
this.parent.style.height = Math.round(this.dimensions.y) + 'px';
if (this.autoSize) {
Expand All @@ -307,7 +303,7 @@
}
this.draw(); // draw calls enforceLimits
// (if you switch to getFrame, call enforceLimits first)
this.dispatchCallback('resized', [this.dimensions]);
this.dispatchCallback('resized', this.dimensions);
return this;
},

Expand Down

0 comments on commit 34e9613

Please sign in to comment.