@@ -43,6 +43,10 @@ dragElement.unhoverRaw = unhover.raw;
43
43
* dragged is as in moveFn
44
44
* numClicks is how many clicks we've registered within
45
45
* a doubleclick time
46
+ * setCursor (optional) function(event)
47
+ * executed on mousemove before mousedown
48
+ * the purpose of this callback is to update the mouse cursor before
49
+ * the click & drag interaction has been initiated
46
50
*/
47
51
dragElement . init = function init ( options ) {
48
52
var gd = Lib . getPlotDiv ( options . element ) || { } ,
@@ -52,11 +56,15 @@ dragElement.init = function init(options) {
52
56
startY ,
53
57
newMouseDownTime ,
54
58
dragCover ,
55
- initialTarget ;
59
+ initialTarget ,
60
+ initialOnMouseMove ;
56
61
57
62
if ( ! gd . _mouseDownTime ) gd . _mouseDownTime = 0 ;
58
63
59
64
function onStart ( e ) {
65
+ // disable call to options.setCursor(evt)
66
+ options . element . onmousemove = initialOnMouseMove ;
67
+
60
68
// make dragging and dragged into properties of gd
61
69
// so that others can look at and modify them
62
70
gd . _dragged = false ;
@@ -107,6 +115,10 @@ dragElement.init = function init(options) {
107
115
}
108
116
109
117
function onDone ( e ) {
118
+ // re-enable call to options.setCursor(evt)
119
+ initialOnMouseMove = options . element . onmousemove ;
120
+ if ( options . setCursor ) options . element . onmousemove = options . setCursor ;
121
+
110
122
dragCover . onmousemove = null ;
111
123
dragCover . onmouseup = null ;
112
124
dragCover . onmouseout = null ;
@@ -139,6 +151,10 @@ dragElement.init = function init(options) {
139
151
return Lib . pauseEvent ( e ) ;
140
152
}
141
153
154
+ // enable call to options.setCursor(evt)
155
+ initialOnMouseMove = options . element . onmousemove ;
156
+ if ( options . setCursor ) options . element . onmousemove = options . setCursor ;
157
+
142
158
options . element . onmousedown = onStart ;
143
159
options . element . style . pointerEvents = 'all' ;
144
160
} ;
0 commit comments