Implement momentum panning - #280
Conversation
There was a problem hiding this comment.
Great concept! I took a quick look through the code and noticed some minor formatting issues.
In your demo, I notice some unexpected behavior:
- If I drag, then stop moving, then release the mouse, the momentum is way higher than I would expect
- If I drag, then stop moving, then release the mouse, I would expect that the momentum should be zero
Perhaps a time component is needed here, as in, when the drag starts, start monitoring the movement with a setInterval or similar, then take the average motion over the last 3 intervals, or something like that.
| startX = x0; | ||
| startY = y0; | ||
|
|
||
| cancelMomentumTracking(); |
There was a problem hiding this comment.
Minor formatting inconsistency
| cancelMomentumTracking(); | |
| cancelMomentumTracking(); |
| t = pointer(t, this); | ||
| if (Math.hypot(touchfirst[0] - t[0], touchfirst[1] - t[1]) < tapDistance) { | ||
| var p = select(this).on("dblclick.zoom"); | ||
| var p = select(this).on('dblclick.zoom'); |
There was a problem hiding this comment.
| var p = select(this).on('dblclick.zoom'); | |
| var p = select(this).on("dblclick.zoom"); |
|
@curran |
|
I'm seeing the same issues that @curran mentioned earlier, where the gesture has accumulated an idea of a movement, even when the user has stopped moving. See this capture: momentum.mp4 |
#67
Demo: https://jsfiddle.net/zmeeva/6urw1s9d/
Usage: