@@ -43,6 +43,10 @@ dragElement.unhoverRaw = unhover.raw;
4343 * dragged is as in moveFn
4444 * numClicks is how many clicks we've registered within
4545 * 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
4650 */
4751dragElement . init = function init ( options ) {
4852 var gd = Lib . getPlotDiv ( options . element ) || { } ,
@@ -52,11 +56,15 @@ dragElement.init = function init(options) {
5256 startY ,
5357 newMouseDownTime ,
5458 dragCover ,
55- initialTarget ;
59+ initialTarget ,
60+ initialOnMouseMove ;
5661
5762 if ( ! gd . _mouseDownTime ) gd . _mouseDownTime = 0 ;
5863
5964 function onStart ( e ) {
65+ // disable call to options.setCursor(evt)
66+ options . element . onmousemove = initialOnMouseMove ;
67+
6068 // make dragging and dragged into properties of gd
6169 // so that others can look at and modify them
6270 gd . _dragged = false ;
@@ -107,6 +115,10 @@ dragElement.init = function init(options) {
107115 }
108116
109117 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+
110122 dragCover . onmousemove = null ;
111123 dragCover . onmouseup = null ;
112124 dragCover . onmouseout = null ;
@@ -139,6 +151,10 @@ dragElement.init = function init(options) {
139151 return Lib . pauseEvent ( e ) ;
140152 }
141153
154+ // enable call to options.setCursor(evt)
155+ initialOnMouseMove = options . element . onmousemove ;
156+ if ( options . setCursor ) options . element . onmousemove = options . setCursor ;
157+
142158 options . element . onmousedown = onStart ;
143159 options . element . style . pointerEvents = 'all' ;
144160} ;
0 commit comments