Skip to content

Conversation

russelldavis
Copy link
Contributor

No description provided.

@mourner
Copy link
Member

mourner commented Aug 3, 2013

Can you explain briefly what was the original the issue?

@russelldavis
Copy link
Contributor Author

The tests should basically explain it (they fail with the original code). If you make a map 1px wider, then call invalidateSize(), then make it 1px wider again, and call invalidateSize() again, the end result should be that the map pans by a total of 1px. With the old code, it would pan by 2px (1px on each call to invalidateSize, due to rounding 0.5 up to 1 each time).

Similarly, if you add 5px to the width, then call invalidateSize(), then subtract 5px from the width and call invalidateSize() again, the end result should not be panned at all. In the old code, it would be panned by 1px, due to rounding issues (2.5px rounds to 3px, -2.5px rounds to 2px)

@travismillerweb
Copy link

This article might help maybe?

http://ejohn.org/blog/sub-pixel-problems-in-css/

On Saturday, August 3, 2013, Russell Davis wrote:

The tests should basically explain it (they fail with the original code).
If you make a map 1px wider, then call invalidateSize(), then make it 1px
wider again, and call invalidateSize() again, the end result should be that
the map pans by a total of 1px. With the old code, it would pan by 2px (1px
on each call to invalidateSize, due to rounding 0.5 up to 1 each time).

Similarly, if you add 5px to the width, then call invalidateSize(), then
subtract 5px from the width and call invalidateSize() again, the end result
should not be panned at all. In the old code, it would be panned by 1px,
due to rounding issues (2.5px rounds to 3px, -2.5px rounds to 2px)


Reply to this email directly or view it on GitHubhttps://github.com//pull/1931#issuecomment-22059694
.

@russelldavis
Copy link
Contributor Author

@tbmiller thanks for the article, but it doesn't really apply here (we're not setting subpixel values), and this pull request solves the issue

@travismillerweb
Copy link

No problem!

On Saturday, August 3, 2013, Russell Davis wrote:

@tbmiller https://github.com/tbmiller thanks for the article, but it
doesn't really apply here (we're not setting subpixel values), and this
pull request solves the issue


Reply to this email directly or view it on GitHubhttps://github.com//pull/1931#issuecomment-22060002
.

@mourner
Copy link
Member

mourner commented Aug 6, 2013

Yeah, looks good — merging now! Thanks!

mourner added a commit that referenced this pull request Aug 6, 2013
Fix rounding issues in Map::invalidateSize
@mourner mourner merged commit e18b7ed into Leaflet:master Aug 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants