6
6
* LICENSE file in the root directory of this source tree.
7
7
*/
8
8
9
-
10
9
'use strict' ;
11
10
12
11
var mouseOffset = require ( 'mouse-event-offset' ) ;
13
12
var hasHover = require ( 'has-hover' ) ;
14
13
var supportsPassive = require ( 'has-passive-events' ) ;
15
14
16
- var Lib = require ( '../../lib' ) ;
17
-
15
+ var removeElement = require ( '../../lib' ) . removeElement ;
18
16
var constants = require ( '../../plots/cartesian/constants' ) ;
19
17
var interactConstants = require ( '../../constants/interactions' ) ;
20
18
@@ -27,7 +25,6 @@ var unhover = require('./unhover');
27
25
dragElement . unhover = unhover . wrapped ;
28
26
dragElement . unhoverRaw = unhover . raw ;
29
27
30
-
31
28
/**
32
29
* Abstracts click & drag interactions
33
30
*
@@ -105,8 +102,7 @@ dragElement.init = function init(options) {
105
102
106
103
if ( ! supportsPassive ) {
107
104
element . ontouchstart = onStart ;
108
- }
109
- else {
105
+ } else {
110
106
if ( element . _ontouchstart ) {
111
107
element . removeEventListener ( 'touchstart' , element . _ontouchstart ) ;
112
108
}
@@ -144,8 +140,7 @@ dragElement.init = function init(options) {
144
140
if ( newMouseDownTime - gd . _mouseDownTime < DBLCLICKDELAY ) {
145
141
// in a click train
146
142
numClicks += 1 ;
147
- }
148
- else {
143
+ } else {
149
144
// new click train
150
145
numClicks = 1 ;
151
146
gd . _mouseDownTime = newMouseDownTime ;
@@ -156,8 +151,7 @@ dragElement.init = function init(options) {
156
151
if ( hasHover && ! rightClick ) {
157
152
dragCover = coverSlip ( ) ;
158
153
dragCover . style . cursor = window . getComputedStyle ( element ) . cursor ;
159
- }
160
- else if ( ! hasHover ) {
154
+ } else if ( ! hasHover ) {
161
155
// document acts as a dragcover for mobile, bc we can't create dragcover dynamically
162
156
dragCover = document ;
163
157
cursor = window . getComputedStyle ( document . documentElement ) . cursor ;
@@ -215,9 +209,8 @@ dragElement.init = function init(options) {
215
209
document . removeEventListener ( 'touchend' , onDone ) ;
216
210
217
211
if ( hasHover ) {
218
- Lib . removeElement ( dragCover ) ;
219
- }
220
- else if ( cursor ) {
212
+ removeElement ( dragCover ) ;
213
+ } else if ( cursor ) {
221
214
dragCover . documentElement . style . cursor = cursor ;
222
215
cursor = null ;
223
216
}
@@ -236,8 +229,7 @@ dragElement.init = function init(options) {
236
229
237
230
if ( gd . _dragged ) {
238
231
if ( options . doneFn ) options . doneFn ( ) ;
239
- }
240
- else {
232
+ } else {
241
233
if ( options . clickFn ) options . clickFn ( numClicks , initialEvent ) ;
242
234
243
235
// If we haven't dragged, this should be a click. But because of the
0 commit comments