Skip to content

Commit 5b59a6e

Browse files
committed
track dragCover and add existance check in maindrag 'mouseout' handler:
- makes click and the mouseout clean call work the maindrag container
1 parent 82513f0 commit 5b59a6e

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

shelly/plotlyjs/static/plotlyjs/src/graph_interact.js

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -121,27 +121,18 @@ fx.init = function(gd) {
121121
})
122122
.mouseout(function(evt) {
123123
/*
124-
* IMPORTANT: `fx.unhover(gd, evt)` has been commented out below
125-
* because in some browsers a 'mouseout' event is fired on clicks
126-
* on the maindrag container before reaching the 'click' handler.
127-
*
128-
* This results in a call to `fx.unhover` before `fx.click` where
129-
* `unhover` sets `gd._hoverdata` to `undefined` causing the call
130-
* to `fx.click` to return early.
131-
*
132-
* Note that the 'mouseout' handler is called only when the mouse
133-
* cursor gets lost. Most 'unhover' calls happen from 'mousemove';
134-
* these are not affected by the change below.
135-
*
136-
* Browsers where this behavior has been noticed:
137-
* - Chrome 46.0.2490.71
138-
* - Firefox 41.0.2
139-
* - IE 9, 10, 11
124+
* IMPORTANT:
125+
* We must check for the presence of the drag cover here.
126+
* If we don't, a 'mouseout' event is trigger on the
127+
* maindrag before each 'click' event, which has the effect
128+
* of cancelling the click event.
140129
*/
141-
// fx.unhover(gd, evt);
142-
return;
130+
if(fullLayout._dragCover) return;
131+
fx.unhover(gd, evt);
143132
})
144-
.click(function(evt){ fx.click(gd,evt); });
133+
.click(function(evt) {
134+
fx.click(gd, evt);
135+
});
145136
// corner draggers
146137
dragBox(gd, plotinfo, -DRAGGERSIZE, -DRAGGERSIZE,
147138
DRAGGERSIZE, DRAGGERSIZE, 'n', 'w');
@@ -2074,6 +2065,7 @@ fx.dragElement = function(options) {
20742065
if(options.prepFn) options.prepFn(e, startX, startY);
20752066

20762067
dragCover = coverSlip();
2068+
gd._fullLayout._dragCover = dragCover;
20772069

20782070
dragCover.onmousemove = onMove;
20792071
dragCover.onmouseup = onDone;
@@ -2099,6 +2091,7 @@ fx.dragElement = function(options) {
20992091
dragCover.onmouseup = null;
21002092
dragCover.onmouseout = null;
21012093
Plotly.Lib.removeElement(dragCover);
2094+
delete gd._fullLayout._dragCover;
21022095

21032096
if(!gd._dragging) {
21042097
gd._dragged = false;

0 commit comments

Comments
 (0)