Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Improved zoom a lot #19
First of all, great work on iScroll! And thanks for providing such a useful library to the community.
I'm helping Bondi build an iPad magazine viewing web app, and we're using iScroll for (a) zooming into the magazine and (b) panning around smoothly while you're zoomed in. We saw some room for improvement (and bug fixes) in your implementation of zoom, so I made those fixes and thought you might find them valuable too. You can view my specific commits for the details, but the two most relevant commits are 2b40324 and ec42671.
Note that I originally forked pre-beta-1, from your Feb 10 "Updated zoom" commit 97e0158 specifically, but I've taken care of merging both of our changes.
Here is the overall summary of what I did:
Hope you find these changes valuable! Let me know if you have any questions; I'd love to get your feedback if you have any issues. Thanks again!
Min and max zoom constraints no longer apply *during* zoom, only *after* now. Like the iPhone's Photos app, the reset is also a smooth animation now. Also, changing the drag-to-pan dampener to 1/2 now when past the edge, instead of the previous 1/2.4, to match the native iOS feel.
Before, logic for recognizing zoom start was inconsistent between: - *one* touchstart event w/ *two* fingers, vs. - *two* touchstart events w/ *one* finger each. Now, the logic is consistent; the same event handlers are added, etc. Before, if the only touchmove events were with two fingers down, they were ignored completely, so the touchend handler would reset x and y, assuming no movement happened. Now, we properly recognize zoom and don't reset then. Together, these almost entirely (but not quite, argh!) eliminate the annoying bug where at the end of a pinch zoom, the content snaps to the top-left. Overall, though, the entire zooming experience is *much* better now.