9
9
10
10
'use strict' ;
11
11
12
- var Plotly = require ( '../../plotly' ) ;
13
12
var d3 = require ( 'd3' ) ;
14
13
var tinycolor = require ( 'tinycolor2' ) ;
15
14
var isNumeric = require ( 'fast-isnumeric' ) ;
15
+
16
+ var Plotly = require ( '../../plotly' ) ;
16
17
var Events = require ( '../../lib/events' ) ;
18
+
17
19
var prepSelect = require ( './select' ) ;
20
+ var constants = require ( './constants' ) ;
18
21
19
22
var fx = module . exports = { } ;
20
23
@@ -68,19 +71,6 @@ fx.isHoriz = function(fullData) {
68
71
return isHoriz ;
69
72
} ;
70
73
71
- // ms between first mousedown and 2nd mouseup to constitute dblclick...
72
- // we don't seem to have access to the system setting
73
- fx . DBLCLICKDELAY = 600 ;
74
-
75
- // pixels to move mouse before you stop clamping to starting point
76
- fx . MINDRAG = 8 ;
77
-
78
- // smallest dimension allowed for a zoombox
79
- fx . MINZOOM = 20 ;
80
-
81
- // width of axis drag regions
82
- var DRAGGERSIZE = 20 ;
83
-
84
74
fx . init = function ( gd ) {
85
75
var fullLayout = gd . _fullLayout ;
86
76
@@ -113,6 +103,7 @@ fx.init = function(gd) {
113
103
// the x position of the main y axis line
114
104
x0 = ( ya . _linepositions [ subplot ] || [ ] ) [ 3 ] ;
115
105
106
+ var DRAGGERSIZE = constants . DRAGGERSIZE ;
116
107
if ( isNumeric ( y0 ) && xa . side === 'top' ) y0 -= DRAGGERSIZE ;
117
108
if ( isNumeric ( x0 ) && ya . side !== 'right' ) x0 -= DRAGGERSIZE ;
118
109
@@ -1458,7 +1449,7 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
1458
1449
y1 = Math . max ( 0 , Math . min ( ph , dy0 + y0 ) ) ,
1459
1450
dx = Math . abs ( x1 - x0 ) ,
1460
1451
dy = Math . abs ( y1 - y0 ) ,
1461
- clen = Math . floor ( Math . min ( dy , dx , fx . MINZOOM ) / 2 ) ;
1452
+ clen = Math . floor ( Math . min ( dy , dx , constants . MINZOOM ) / 2 ) ;
1462
1453
1463
1454
box . l = Math . min ( x0 , x1 ) ;
1464
1455
box . r = Math . max ( x0 , x1 ) ;
@@ -1467,8 +1458,8 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
1467
1458
1468
1459
// look for small drags in one direction or the other,
1469
1460
// and only drag the other axis
1470
- if ( ! yActive || dy < Math . min ( Math . max ( dx * 0.6 , fx . MINDRAG ) , fx . MINZOOM ) ) {
1471
- if ( dx < fx . MINDRAG ) {
1461
+ if ( ! yActive || dy < Math . min ( Math . max ( dx * 0.6 , constants . MINDRAG ) , constants . MINZOOM ) ) {
1462
+ if ( dx < constants . MINDRAG ) {
1472
1463
zoomMode = '' ;
1473
1464
box . r = box . l ;
1474
1465
box . t = box . b ;
@@ -1479,21 +1470,21 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
1479
1470
box . b = ph ;
1480
1471
zoomMode = 'x' ;
1481
1472
corners . attr ( 'd' ,
1482
- 'M' + ( box . l - 0.5 ) + ',' + ( y0 - fx . MINZOOM - 0.5 ) +
1483
- 'h-3v' + ( 2 * fx . MINZOOM + 1 ) + 'h3ZM' +
1484
- ( box . r + 0.5 ) + ',' + ( y0 - fx . MINZOOM - 0.5 ) +
1485
- 'h3v' + ( 2 * fx . MINZOOM + 1 ) + 'h-3Z' ) ;
1473
+ 'M' + ( box . l - 0.5 ) + ',' + ( y0 - constants . MINZOOM - 0.5 ) +
1474
+ 'h-3v' + ( 2 * constants . MINZOOM + 1 ) + 'h3ZM' +
1475
+ ( box . r + 0.5 ) + ',' + ( y0 - constants . MINZOOM - 0.5 ) +
1476
+ 'h3v' + ( 2 * constants . MINZOOM + 1 ) + 'h-3Z' ) ;
1486
1477
}
1487
1478
}
1488
- else if ( ! xActive || dx < Math . min ( dy * 0.6 , fx . MINZOOM ) ) {
1479
+ else if ( ! xActive || dx < Math . min ( dy * 0.6 , constants . MINZOOM ) ) {
1489
1480
box . l = 0 ;
1490
1481
box . r = pw ;
1491
1482
zoomMode = 'y' ;
1492
1483
corners . attr ( 'd' ,
1493
- 'M' + ( x0 - fx . MINZOOM - 0.5 ) + ',' + ( box . t - 0.5 ) +
1494
- 'v-3h' + ( 2 * fx . MINZOOM + 1 ) + 'v3ZM' +
1495
- ( x0 - fx . MINZOOM - 0.5 ) + ',' + ( box . b + 0.5 ) +
1496
- 'v3h' + ( 2 * fx . MINZOOM + 1 ) + 'v-3Z' ) ;
1484
+ 'M' + ( x0 - constants . MINZOOM - 0.5 ) + ',' + ( box . t - 0.5 ) +
1485
+ 'v-3h' + ( 2 * constants . MINZOOM + 1 ) + 'v3ZM' +
1486
+ ( x0 - constants . MINZOOM - 0.5 ) + ',' + ( box . b + 0.5 ) +
1487
+ 'v3h' + ( 2 * constants . MINZOOM + 1 ) + 'v-3Z' ) ;
1497
1488
}
1498
1489
else {
1499
1490
zoomMode = 'xy' ;
@@ -1545,7 +1536,7 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
1545
1536
}
1546
1537
1547
1538
function zoomDone ( dragged , numClicks ) {
1548
- if ( Math . min ( box . h , box . w ) < fx . MINDRAG * 2 ) {
1539
+ if ( Math . min ( box . h , box . w ) < constants . MINDRAG * 2 ) {
1549
1540
if ( numClicks === 2 ) doubleClick ( ) ;
1550
1541
else pauseForDrag ( gd ) ;
1551
1542
@@ -1904,7 +1895,7 @@ function pauseForDrag(gd) {
1904
1895
gd . _replotPending = deferredReplot ;
1905
1896
finishDrag ( gd ) ;
1906
1897
} ,
1907
- fx . DBLCLICKDELAY ) ;
1898
+ constants . DBLCLICKDELAY ) ;
1908
1899
}
1909
1900
1910
1901
function finishDrag ( gd ) {
@@ -2005,7 +1996,7 @@ fx.dragElement = function(options) {
2005
1996
initialTarget = e . target ;
2006
1997
2007
1998
newMouseDownTime = ( new Date ( ) ) . getTime ( ) ;
2008
- if ( newMouseDownTime - gd . _mouseDownTime < fx . DBLCLICKDELAY ) {
1999
+ if ( newMouseDownTime - gd . _mouseDownTime < constants . DBLCLICKDELAY ) {
2009
2000
// in a click train
2010
2001
numClicks += 1 ;
2011
2002
}
@@ -2031,7 +2022,7 @@ fx.dragElement = function(options) {
2031
2022
function onMove ( e ) {
2032
2023
var dx = e . clientX - startX ,
2033
2024
dy = e . clientY - startY ,
2034
- minDrag = options . minDrag || fx . MINDRAG ;
2025
+ minDrag = options . minDrag || constants . MINDRAG ;
2035
2026
2036
2027
if ( Math . abs ( dx ) < minDrag ) dx = 0 ;
2037
2028
if ( Math . abs ( dy ) < minDrag ) dy = 0 ;
@@ -2056,7 +2047,7 @@ fx.dragElement = function(options) {
2056
2047
2057
2048
// don't count as a dblClick unless the mouseUp is also within
2058
2049
// the dblclick delay
2059
- if ( ( new Date ( ) ) . getTime ( ) - gd . _mouseDownTime > fx . DBLCLICKDELAY ) {
2050
+ if ( ( new Date ( ) ) . getTime ( ) - gd . _mouseDownTime > constants . DBLCLICKDELAY ) {
2060
2051
numClicks = Math . max ( numClicks - 1 , 1 ) ;
2061
2052
}
2062
2053
0 commit comments