Skip to content

Doubleclick - Drag bug [Fixes #333] #355

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

Merged
merged 12 commits into from
Mar 29, 2016
Merged

Doubleclick - Drag bug [Fixes #333] #355

merged 12 commits into from
Mar 29, 2016

Conversation

mdtusz
Copy link
Contributor

@mdtusz mdtusz commented Mar 24, 2016

Fixes #333

In Brief

  • shorten DBLCLICKDELAY from 600 to 300
  • remove pauseForDrag method and calls - this prevented the next mouse actions from completing until after a DBLCLICKDELAY delay
  • removed unused artifact code from pre-open-source days

Concerns

I can't see any areas that rely on the behaviour of the pauseForDrag call, and nothing appears to be broken by the changes, but it is possible there is some user-interaction that may not behave properly if this delay is removed.

@alexcjohnson @etpinard

@mdtusz mdtusz added bug something broken status: reviewable labels Mar 24, 2016
@alexcjohnson
Copy link
Collaborator

Interesting... I'm not entirely sure what condition pauseForDrag was supposed to catch but I do recall it being another edge case. I suppose it's hard to figure out from git because it's from long before reorganizing the repo, huh?

So that we don't recreate whatever problem it was though, what about a different solution: whenever finishDrag gets called, call clearTimeout on the one in pauseForDrag. That's probably the issue, right? That finishDrag gets called once for the doubleclick and then again when the timeout triggers, even though at that point your mouse is down so a finishDrag erroneously resets the flags telling us what's happening? Alternatively we could abort finishDrag if it looks like the mouse is down, but in that case I'd worry about what happens when you mouse out of the window while dragging.

@mdtusz
Copy link
Contributor Author

mdtusz commented Mar 24, 2016

Hmm. I was hoping that either you or Etienne would be familiar with pauseForDrag.

The core issue is that gd._dragging is set to true, and isn't set back to false (by finishDrag) soon enough so that this block is never passed.

Regardless, I'm unsure that the code has another purpose now - as far as I can reason about, it is simply a delay of DBLCLICKDELAY where no other "actions" can be made, but this seems to be arbitrary.

If we can decipher why it should be left in, I'm happy to change it, but I would prefer to have a small interaction bug crop up in the future so that we can write a tested and robust solution, rather than to leave in code that might be important, but nobody quite knows for sure. Additionally, adding a clearTimeout would be fairly messy as there is no shared scope (other than window) for pauseForDrag and finishDrag. It could be set as a gd property, but it is already a fairly cluttered object as it is.

@alexcjohnson
Copy link
Collaborator

Ok, makes sense. I found where this went in, it was when I made the plotlyjs showcase for streambed - https://github.com/plotly/streambed/pull/1176

Unfortunately I don't see that I discussed why at that point, but at the very least we should be able to run the examples in there against this branch and see if something fails. Remember to try all 3 different kinds of Cartesian drag/zoom regions (plot, single axis, and corner) as well as plots with enough data that you need more than DBLCLICKDELAY to redraw - that's what the comment seems to say, that if you don't do this, then in some cases you get a redraw (and its associated events, which may be what I cared most about for the showcase, but the redraw itself could be problematic too if it flashes or slows stuff too much) on the first click of what will ultimately be a double click.

- move copy-mock step and add-custom-matchers to suite scope
- rewrite one test as promise chain
- define auto range values in suite scope
- large drag values resulted in failed tests in small window sizes

return [
corners.nw.x + (corners.ne.x - corners.nw.x) / 2,
corners.ne.y + (corners.se.y - corners.ne.y) / 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @mdtusz

@etpinard etpinard merged commit e03e9e0 into master Mar 29, 2016
@etpinard etpinard deleted the zoom-click-bug branch March 29, 2016 17:37
@alexcjohnson
Copy link
Collaborator

Maybe I'm getting old and slow, but since I merged this into my WIP I find DBLCLICKDELAY is too fast for me... I only successfully generate a doubleclick about 2/3 of the time. Was the drop from 600 to 300 important to this fix, or did it just reduce the frequency of the bug before you implemented the real fix? Can we bump it back up? Really annoying that JS doesn't have access to the OS-defined doubleclick timing but I guess there's nothing we can do about that.

@mdtusz
Copy link
Contributor Author

mdtusz commented Apr 1, 2016

We can use the OS double click delay, but as far as I know, only through doubleclick events - I've never found a ms value as an accessible property though. The change was made initially in an effort to fix the bug, but then left because 600ms seemed like it was too long - mobile browsers used to use 300ms as the delay time to look for double taps, and Windows default timing is set to 500ms (I have no idea what the OSX default is - I assume the same though) - I wanted to err on the side of speediness.

That said, I have no issue changing it back!

@alexcjohnson
Copy link
Collaborator

Ok, I'd vote for 500 then, Windows probably sets a precedent that will work for most people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants