99
1010'use strict' ;
1111
12- var Plotly = require ( '../../plotly' ) ;
1312var d3 = require ( 'd3' ) ;
1413var tinycolor = require ( 'tinycolor2' ) ;
1514var isNumeric = require ( 'fast-isnumeric' ) ;
15+
16+ var Plotly = require ( '../../plotly' ) ;
1617var Events = require ( '../../lib/events' ) ;
18+
1719var prepSelect = require ( './select' ) ;
20+ var constants = require ( './constants' ) ;
1821
1922var fx = module . exports = { } ;
2023
@@ -68,19 +71,6 @@ fx.isHoriz = function(fullData) {
6871 return isHoriz ;
6972} ;
7073
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-
8474fx . init = function ( gd ) {
8575 var fullLayout = gd . _fullLayout ;
8676
@@ -113,6 +103,7 @@ fx.init = function(gd) {
113103 // the x position of the main y axis line
114104 x0 = ( ya . _linepositions [ subplot ] || [ ] ) [ 3 ] ;
115105
106+ var DRAGGERSIZE = constants . DRAGGERSIZE ;
116107 if ( isNumeric ( y0 ) && xa . side === 'top' ) y0 -= DRAGGERSIZE ;
117108 if ( isNumeric ( x0 ) && ya . side !== 'right' ) x0 -= DRAGGERSIZE ;
118109
@@ -1458,7 +1449,7 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
14581449 y1 = Math . max ( 0 , Math . min ( ph , dy0 + y0 ) ) ,
14591450 dx = Math . abs ( x1 - x0 ) ,
14601451 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 ) ;
14621453
14631454 box . l = Math . min ( x0 , x1 ) ;
14641455 box . r = Math . max ( x0 , x1 ) ;
@@ -1467,8 +1458,8 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
14671458
14681459 // look for small drags in one direction or the other,
14691460 // 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 ) {
14721463 zoomMode = '' ;
14731464 box . r = box . l ;
14741465 box . t = box . b ;
@@ -1479,21 +1470,21 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
14791470 box . b = ph ;
14801471 zoomMode = 'x' ;
14811472 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' ) ;
14861477 }
14871478 }
1488- else if ( ! xActive || dx < Math . min ( dy * 0.6 , fx . MINZOOM ) ) {
1479+ else if ( ! xActive || dx < Math . min ( dy * 0.6 , constants . MINZOOM ) ) {
14891480 box . l = 0 ;
14901481 box . r = pw ;
14911482 zoomMode = 'y' ;
14921483 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' ) ;
14971488 }
14981489 else {
14991490 zoomMode = 'xy' ;
@@ -1545,7 +1536,7 @@ function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
15451536 }
15461537
15471538 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 ) {
15491540 if ( numClicks === 2 ) doubleClick ( ) ;
15501541 else pauseForDrag ( gd ) ;
15511542
@@ -1904,7 +1895,7 @@ function pauseForDrag(gd) {
19041895 gd . _replotPending = deferredReplot ;
19051896 finishDrag ( gd ) ;
19061897 } ,
1907- fx . DBLCLICKDELAY ) ;
1898+ constants . DBLCLICKDELAY ) ;
19081899}
19091900
19101901function finishDrag ( gd ) {
@@ -2005,7 +1996,7 @@ fx.dragElement = function(options) {
20051996 initialTarget = e . target ;
20061997
20071998 newMouseDownTime = ( new Date ( ) ) . getTime ( ) ;
2008- if ( newMouseDownTime - gd . _mouseDownTime < fx . DBLCLICKDELAY ) {
1999+ if ( newMouseDownTime - gd . _mouseDownTime < constants . DBLCLICKDELAY ) {
20092000 // in a click train
20102001 numClicks += 1 ;
20112002 }
@@ -2031,7 +2022,7 @@ fx.dragElement = function(options) {
20312022 function onMove ( e ) {
20322023 var dx = e . clientX - startX ,
20332024 dy = e . clientY - startY ,
2034- minDrag = options . minDrag || fx . MINDRAG ;
2025+ minDrag = options . minDrag || constants . MINDRAG ;
20352026
20362027 if ( Math . abs ( dx ) < minDrag ) dx = 0 ;
20372028 if ( Math . abs ( dy ) < minDrag ) dy = 0 ;
@@ -2056,7 +2047,7 @@ fx.dragElement = function(options) {
20562047
20572048 // don't count as a dblClick unless the mouseUp is also within
20582049 // the dblclick delay
2059- if ( ( new Date ( ) ) . getTime ( ) - gd . _mouseDownTime > fx . DBLCLICKDELAY ) {
2050+ if ( ( new Date ( ) ) . getTime ( ) - gd . _mouseDownTime > constants . DBLCLICKDELAY ) {
20602051 numClicks = Math . max ( numClicks - 1 , 1 ) ;
20612052 }
20622053
0 commit comments