Prioritize User-feedback •Don’t do any loading during gestures •Treat the DOM as write-only (do your own math) •When at all possible, use css transitions
Snap back/snap forward • Keep track of last position, use transitions with easing to snap back •Pick a swipe distance threshold, use that to snap forward (ontouchend) •If the user is gesturing, the element must be moving
A Word about scrolling •Use native if at all possible: •-webkit-overflow-scrolling: touch; •If not, use a library to simulate momentum scroll (iScroll 4, Scrollability)
What is happening? •Determine Center of the touch points •Determine the scale factor (touch.scale) •Scale the element by the scale factor, with the center of the touch points as the scale center
•Feature Detect •Add transitions, don’t depend on them •Gesture interaction is an enhancement, clicks should still work •Be able to disable features per user- agent, if necessary Progressive Enhancement
Swiping Process •Event Listener on top level for touch events •Only visible nodes move via translate3d •Rebuild next/previous happens when movement stops.
Frustrating Limitations •Retina screen is huge, device memory is small •Hardware acceleration is a crash festival •Fighting automatic optimization http://bit.ly/apple-image-size-restrictions