1010'use strict' ;
1111
1212var mouseOffset = require ( 'mouse-event-offset' ) ;
13- var hasHover = require ( 'has-hover' ) ;
1413
1514var Plotly = require ( '../../plotly' ) ;
1615var Lib = require ( '../../lib' ) ;
@@ -30,13 +29,6 @@ dragElement.unhoverRaw = unhover.raw;
3029/**
3130 * Abstracts click & drag interactions
3231 *
33- * During the interaction, a "coverSlip" element - a transparent
34- * div covering the whole page - is created, which has two key effects:
35- * - Lets you drag beyond the boundaries of the plot itself without
36- * dropping (but if you drag all the way out of the browser window the
37- * interaction will end)
38- * - Freezes the cursor: whatever mouse cursor the drag element had when the
39- * interaction started gets copied to the coverSlip for use until mouseup
4032 *
4133 * @param {object } options with keys:
4234 * element (required) the DOM element to drag
@@ -65,19 +57,14 @@ dragElement.init = function init(options) {
6557 startY ,
6658 newMouseDownTime ,
6759 cursor ,
68- dragCover ,
6960 initialTarget ;
7061
7162 if ( ! gd . _mouseDownTime ) gd . _mouseDownTime = 0 ;
7263
7364 options . element . style . pointerEvents = 'all' ;
7465
75- if ( hasHover ) {
76- options . element . onmousedown = onStart ;
77- }
78- else {
79- options . element . ontouchstart = onStart ;
80- }
66+ options . element . onmousedown = onStart ;
67+ options . element . ontouchstart = onStart ;
8168
8269 function onStart ( e ) {
8370 // make dragging and dragged into properties of gd
@@ -102,24 +89,16 @@ dragElement.init = function init(options) {
10289
10390 if ( options . prepFn ) options . prepFn ( e , startX , startY ) ;
10491
105- if ( hasHover ) {
106- dragCover = coverSlip ( ) ;
107- dragCover . addEventListener ( 'mousemove' , onMove ) ;
108- dragCover . addEventListener ( 'mouseup' , onDone ) ;
109- dragCover . addEventListener ( 'mouseout' , onDone ) ;
110-
111- dragCover . style . cursor = window . getComputedStyle ( options . element ) . cursor ;
112- }
11392
11493 // document acts as a dragcover for mobile, bc we can't create dragcover dynamically
115- else {
116- dragCover = document ;
117- document . addEventListener ( 'touchmove' , onMove ) ;
118- document . addEventListener ( 'touchend' , onDone ) ;
94+ document . addEventListener ( 'mousemove' , onMove ) ;
95+ document . addEventListener ( 'mouseup' , onDone ) ;
96+ document . addEventListener ( 'mouseout' , onDone ) ;
97+ document . addEventListener ( 'touchmove' , onMove ) ;
98+ document . addEventListener ( 'touchend' , onDone ) ;
11999
120- cursor = window . getComputedStyle ( document . documentElement ) . cursor ;
121- document . documentElement . style . cursor = window . getComputedStyle ( options . element ) . cursor ;
122- }
100+ cursor = window . getComputedStyle ( document . documentElement ) . cursor ;
101+ document . documentElement . style . cursor = window . getComputedStyle ( options . element ) . cursor ;
123102
124103
125104 return Lib . pauseEvent ( e ) ;
@@ -144,25 +123,17 @@ dragElement.init = function init(options) {
144123 }
145124
146125 function onDone ( e ) {
147- if ( hasHover ) {
148- dragCover . removeEventListener ( 'mousemove' , onMove ) ;
149- dragCover . removeEventListener ( 'mouseup' , onDone ) ;
150- dragCover . removeEventListener ( 'mouseout' , onDone ) ;
151-
152- Lib . removeElement ( dragCover ) ;
126+ document . removeEventListener ( 'mousemove' , onMove ) ;
127+ document . removeEventListener ( 'mouseup' , onDone ) ;
128+ document . removeEventListener ( 'mouseout' , onDone ) ;
129+ document . removeEventListener ( 'touchmove' , onMove ) ;
130+ document . removeEventListener ( 'touchend' , onDone ) ;
131+
132+ if ( cursor ) {
133+ document . documentElement . style . cursor = cursor ;
134+ cursor = null ;
153135 }
154136
155- else {
156- dragCover . removeEventListener ( 'touchmove' , onMove ) ;
157- dragCover . removeEventListener ( 'touchend' , onDone ) ;
158-
159- if ( cursor ) {
160- dragCover . documentElement . style . cursor = cursor ;
161- cursor = null ;
162- }
163- }
164-
165-
166137 if ( ! gd . _dragging ) {
167138 gd . _dragged = false ;
168139 return ;
0 commit comments