Drag point changes after initial drag
See original GitHub issueIs there a reason to remove the initial drag distance in function _renderMovement (and never add it back)? I think this is a bug. To illustrate, position the mouse pointer over a defined point in the image, click and drag quickly. The mouse pointer should remain over the initial click point. But it will change by the amount subtracted below:
if(_isFirstMove) {
_isFirstMove = false;
// subtract drag distance that was used during the detection direction
if( Math.abs(delta.x) >= DIRECTION_CHECK_OFFSET) {
delta.x -= _currentPoints[0].x - _startPoint.x;
}
if( Math.abs(delta.y) >= DIRECTION_CHECK_OFFSET) {
delta.y -= _currentPoints[0].y - _startPoint.y;
}
}
When panning an image quickly it adds inertia to the drag that is never recovered.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Drag operations - Web APIs - MDN Web Docs - Mozilla
When an image or link is dragged, the URL of the image or link is set as the drag data, and a drag...
Read more >7.7 Drag and drop — HTML5 - W3C
To make an element draggable is simple: give the element a draggable attribute, and set an event listener for dragstart that stores the...
Read more >Using the HTML5 Drag and Drop API - web.dev
The HTML5 Drag and Drop API means that we can make almost any element on our page draggable. In this post we'll explain...
Read more >Drag'n'Drop with mouse events - The Modern JavaScript Tutorial
Drag 'n'Drop algorithm · On mousedown – prepare the element for moving, if needed (maybe create a clone of it, add a class...
Read more >Drag and drop - Android Developers
Text string and image being dragged and dropped between apps in split-screen mode. Figure 1. Drag and drop within an app. Figure 2....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
OK, after playing around with this on touch vs. non-touch devices I think I better understand the issue.
First of all, the concept of an initial drag threshold is only pertinent to touch devices. We need to differentiate between a drag and a tap, because fingers are not precicse. If the user is using a mouse or precision pointer we shouldn’t apply an initial drag threshold (because mice are precise).
Also, to the extent we choose to apply a minimum initial drag threshold, we should subtract the initial drag (less than the threshold) for smoothness. This is what the code is trying to do, but it actually isn’t smooth because it only subtracts the initial drag in ONE direction. For smoothness it should subtract the initial drag in BOTH directions. Also, the initial drag threshold should be checked against the distance dragged NOT the direction dragged. Remember, the goal is differentiate between a finger tap and a drag, not force the user to drag in any one direction! Note the current code makes it very difficult to pan at an angle (when zoomed in).
Here is the correct way (in my humble opinion) 😃 to handle this.
I agree with most of your statements. The fix will be included in the next major update. Thanks!