-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix #2598 - sloppy click on cartesian zoom #2649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,6 +252,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { | |
zb, | ||
corners; | ||
|
||
// zoom takes over minDrag, so it also has to take over gd._dragged | ||
var zoomDragged; | ||
|
||
// collected changes to be made to the plot by relayout at the end | ||
var updates = {}; | ||
|
||
|
@@ -266,6 +269,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { | |
path0 = 'M0,0H' + pw + 'V' + ph + 'H0V0'; | ||
dimmed = false; | ||
zoomMode = 'xy'; | ||
zoomDragged = false; | ||
|
||
zb = makeZoombox(zoomlayer, lum, xs, ys, path0); | ||
|
||
|
@@ -341,6 +345,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { | |
box.w = box.r - box.l; | ||
box.h = box.b - box.t; | ||
|
||
if(zoomMode) zoomDragged = true; | ||
gd._dragged = zoomDragged; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this one move in |
||
|
||
updateZoombox(zb, corners, box, path0, dimmed, lum); | ||
dimmed = true; | ||
} | ||
|
@@ -458,12 +465,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { | |
// no more scrolling is coming | ||
redrawTimer = setTimeout(function() { | ||
scrollViewBox = [0, 0, pw, ph]; | ||
|
||
var zoomMode; | ||
if(isSubplotConstrained) zoomMode = 'xy'; | ||
else zoomMode = (ew ? 'x' : '') + (ns ? 'y' : ''); | ||
|
||
dragTail(zoomMode); | ||
dragTail(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch, |
||
}, REDRAWDELAY); | ||
|
||
e.preventDefault(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ var Lib = require('../../../src/lib'); | |
* @param {bool} cancelContext: act as though `preventDefault` was called during a `contextmenu` | ||
* handler, which stops native contextmenu and therefore allows mouseup events to be fired. | ||
* Only relevant if button=2 or ctrlKey=true. | ||
* @param {array(2)} opts.slop - shift [x, y] between mousedown and mouseup. | ||
* Just for testing purposes, to simulate a sloppy click | ||
*/ | ||
module.exports = function click(x, y, optsIn) { | ||
var opts = Lib.extendFlat({}, optsIn || {}); | ||
|
@@ -43,10 +45,16 @@ module.exports = function click(x, y, optsIn) { | |
|
||
var downOpts = Lib.extendFlat({buttons: buttons}, opts); | ||
var upOpts = opts; | ||
var slop = opts.slop || []; | ||
var slopX = slop[0] || 0; | ||
var slopY = slop[1] || 0; | ||
var slopOpts = Lib.extendFlat({}, downOpts); | ||
delete slopOpts.button; | ||
|
||
mouseEvent('mousemove', x, y, moveOpts); | ||
mouseEvent('mousedown', x, y, downOpts); | ||
if(callContext) mouseEvent('contextmenu', x, y, downOpts); | ||
if(slopX || slopY) mouseEvent('mousemove', x + slopX, y + slopY, slopOpts); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure -> c56f223 |
||
if(!callContext) mouseEvent('mouseup', x, y, upOpts); | ||
if(!rightClick) mouseEvent('click', x, y, upOpts); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is in
zoomPrep