Skip to content

Commit a30155d

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 b28de25 commit a30155d

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
@@ -122,27 +122,18 @@ fx.init = function(gd) {
122122
})
123123
.mouseout(function(evt) {
124124
/*
125-
* IMPORTANT: `fx.unhover(gd, evt)` has been commented out below
126-
* because in some browsers a 'mouseout' event is fired on clicks
127-
* on the maindrag container before reaching the 'click' handler.
128-
*
129-
* This results in a call to `fx.unhover` before `fx.click` where
130-
* `unhover` sets `gd._hoverdata` to `undefined` causing the call
131-
* to `fx.click` to return early.
132-
*
133-
* Note that the 'mouseout' handler is called only when the mouse
134-
* cursor gets lost. Most 'unhover' calls happen from 'mousemove';
135-
* these are not affected by the change below.
136-
*
137-
* Browsers where this behavior has been noticed:
138-
* - Chrome 46.0.2490.71
139-
* - Firefox 41.0.2
140-
* - IE 9, 10, 11
125+
* IMPORTANT:
126+
* We must check for the presence of the drag cover here.
127+
* If we don't, a 'mouseout' event is trigger on the
128+
* maindrag before each 'click' event, which has the effect
129+
* of cancelling the click event.
141130
*/
142-
// fx.unhover(gd, evt);
143-
return;
131+
if(fullLayout._dragCover) return;
132+
fx.unhover(gd, evt);
144133
})
145-
.click(function(evt){ fx.click(gd,evt); });
134+
.click(function(evt) {
135+
fx.click(gd, evt);
136+
});
146137
// corner draggers
147138
dragBox(gd, plotinfo, -DRAGGERSIZE, -DRAGGERSIZE,
148139
DRAGGERSIZE, DRAGGERSIZE, 'n', 'w');
@@ -2079,6 +2070,7 @@ fx.dragElement = function(options) {
20792070
if(options.prepFn) options.prepFn(e, startX, startY);
20802071

20812072
dragCover = coverSlip();
2073+
gd._fullLayout._dragCover = dragCover;
20822074

20832075
dragCover.onmousemove = onMove;
20842076
dragCover.onmouseup = onDone;
@@ -2104,6 +2096,7 @@ fx.dragElement = function(options) {
21042096
dragCover.onmouseup = null;
21052097
dragCover.onmouseout = null;
21062098
Plotly.Lib.removeElement(dragCover);
2099+
delete gd._fullLayout._dragCover;
21072100

21082101
if(!gd._dragging) {
21092102
gd._dragged = false;

0 commit comments

Comments
 (0)