material-motion-js
material-motion-js copied to clipboard
Implement pinch stream
Take the pointersStream
(#64) and transform it into a stream of scaling coefficients representing the ratio of the current distance-between-pointers from the starting distance-between-pointers.
This is probably just using the Pythagorean Theorem to compute the distance between the current pointers and scan
ning over them to compute the ratio.
Open question:
- What happens if there are more than two pointers down at once?
- Probably treat it as invalid input and do nothing. It will kill the direct manipulation metaphor if you try to compute a linear scale with more than two points; you can't guarantee the pointers moved in unison.
- Is this an acceptable user experience? What if the user has a dirty touchscreen, cause a pointer to appear (and stay fixed) in a single place?
- That might not be worth solving for. If the touchscreen is dirty enough that flaky pointers are being added, it will also convert drags to pinches, which will start breaking the experience anyway.
- Is this an acceptable user experience? What if the user has a dirty touchscreen, cause a pointer to appear (and stay fixed) in a single place?
- Probably treat it as invalid input and do nothing. It will kill the direct manipulation metaphor if you try to compute a linear scale with more than two points; you can't guarantee the pointers moved in unison.
- What happens if the user adds a pointer and then removes a pointer, so you have two different pointers than you started with?
- Probably the same thing as if the user released all the pointers (instead of adding a third) and start fresh when you have two pointers again.
- The deltas between frames are probably so small that even if this did the wrong thing, nobody would notice.
💻 I'm working on a diff at http://codereview.cc/D1692