Skip to content

Commit 1773234

Browse files
committed
Merge pull request #4359 from plotly/click-event-madness
Click event madness part II [fixes #4310]
2 parents e8fd49d + 371b6d6 commit 1773234

File tree

2 files changed

+24
-30
lines changed

2 files changed

+24
-30
lines changed

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

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -114,35 +114,30 @@ fx.init = function(gd) {
114114
// mousemove events for all data hover effects
115115
var maindrag = dragBox(gd, plotinfo, 0, 0,
116116
xa._length, ya._length,'ns','ew');
117-
$(maindrag)
118-
.mousemove(function(evt){
119-
fx.hover(gd,evt,subplot);
120-
fullLayout._lasthover = maindrag;
121-
fullLayout._hoversubplot = subplot;
122-
})
123-
.mouseout(function(evt) {
124-
/*
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
141-
*/
142-
// fx.unhover(gd, evt);
143-
return;
144-
})
145-
.click(function(evt){ fx.click(gd,evt); });
117+
118+
maindrag.onmousemove = function(evt) {
119+
fx.hover(gd, evt, subplot);
120+
fullLayout._lasthover = maindrag;
121+
fullLayout._hoversubplot = subplot;
122+
};
123+
124+
/*
125+
* IMPORTANT:
126+
* We must check for the presence of the drag cover here.
127+
* If we don't, a 'mouseout' event is triggered on the
128+
* maindrag before each 'click' event, which has the effect
129+
* of clearing the hoverdata; thus, cancelling the click event.
130+
*/
131+
maindrag.onmouseout = function(evt) {
132+
if(gd._dragging) return;
133+
134+
fx.unhover(gd, evt);
135+
};
136+
137+
maindrag.onclick = function(evt) {
138+
fx.click(gd, evt);
139+
};
140+
146141
// corner draggers
147142
dragBox(gd, plotinfo, -DRAGGERSIZE, -DRAGGERSIZE,
148143
DRAGGERSIZE, DRAGGERSIZE, 'n', 'w');

shelly/plotlyjs/static/plotlyjs/src/graph_obj.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,6 @@ plots.purge = function(gd) {
19411941

19421942
delete gd.fid;
19431943

1944-
19451944
delete gd.undoqueue; // action queue
19461945
delete gd.undonum;
19471946
delete gd.autoplay; // are we doing an action that doesn't go in undo queue?

0 commit comments

Comments
 (0)