Skip to content

Commit 4054c28

Browse files
committed
replace DBLCLICKDELAY interaction constant with doubleClickDelay dflt
1 parent a5040d4 commit 4054c28

File tree

11 files changed

+16
-24
lines changed

11 files changed

+16
-24
lines changed

src/components/dragelement/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ var supportsPassive = require('has-passive-events');
1414

1515
var removeElement = require('../../lib').removeElement;
1616
var constants = require('../../plots/cartesian/constants');
17-
var interactConstants = require('../../constants/interactions');
1817

1918
var dragElement = module.exports = {};
2019

@@ -82,7 +81,7 @@ dragElement.unhoverRaw = unhover.raw;
8281
dragElement.init = function init(options) {
8382
var gd = options.gd;
8483
var numClicks = 1;
85-
var DBLCLICKDELAY = (gd._context && gd._context.doubleClickDelay) ? gd._context.doubleClickDelay : interactConstants.DBLCLICKDELAY;
84+
var doubleClickDelay = gd._context.doubleClickDelay;
8685
var element = options.element;
8786

8887
var startX,
@@ -137,7 +136,7 @@ dragElement.init = function init(options) {
137136
}
138137

139138
newMouseDownTime = (new Date()).getTime();
140-
if(newMouseDownTime - gd._mouseDownTime < DBLCLICKDELAY) {
139+
if(newMouseDownTime - gd._mouseDownTime < doubleClickDelay) {
141140
// in a click train
142141
numClicks += 1;
143142
} else {
@@ -223,7 +222,7 @@ dragElement.init = function init(options) {
223222

224223
// don't count as a dblClick unless the mouseUp is also within
225224
// the dblclick delay
226-
if((new Date()).getTime() - gd._mouseDownTime > DBLCLICKDELAY) {
225+
if((new Date()).getTime() - gd._mouseDownTime > doubleClickDelay) {
227226
numClicks = Math.max(numClicks - 1, 1);
228227
}
229228

src/components/legend/draw.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ var svgTextUtils = require('../../lib/svg_text_utils');
2121
var handleClick = require('./handle_click');
2222

2323
var constants = require('./constants');
24-
var interactConstants = require('../../constants/interactions');
2524
var alignmentConstants = require('../../constants/alignment');
2625
var LINE_SPACING = alignmentConstants.LINE_SPACING;
2726
var FROM_TL = alignmentConstants.FROM_TL;
@@ -31,12 +30,9 @@ var getLegendData = require('./get_legend_data');
3130
var style = require('./style');
3231
var helpers = require('./helpers');
3332

34-
var DBLCLICKDELAY = interactConstants.DBLCLICKDELAY;
35-
3633
module.exports = function draw(gd) {
3734
var fullLayout = gd._fullLayout;
3835
var clipId = 'legend' + fullLayout._uid;
39-
DBLCLICKDELAY = (gd._context && gd._context.doubleClickDelay) ? gd._context.doubleClickDelay : DBLCLICKDELAY;
4036

4137
if(!fullLayout._infolayer || !gd.calcdata) return;
4238

@@ -385,7 +381,7 @@ function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) {
385381
if(numClicks === 1) {
386382
legend._clickTimeout = setTimeout(function() {
387383
handleClick(legendItem, gd, numClicks);
388-
}, DBLCLICKDELAY);
384+
}, gd._context.doubleClickDelay);
389385
} else if(numClicks === 2) {
390386
if(legend._clickTimeout) clearTimeout(legend._clickTimeout);
391387
gd._legendMouseDownTime = 0;
@@ -469,6 +465,7 @@ function ensureLength(str, maxLength) {
469465
}
470466

471467
function setupTraceToggle(g, gd) {
468+
var doubleClickDelay = gd._context.doubleClickDelay;
472469
var newMouseDownTime;
473470
var numClicks = 1;
474471

@@ -480,7 +477,7 @@ function setupTraceToggle(g, gd) {
480477

481478
traceToggle.on('mousedown', function() {
482479
newMouseDownTime = (new Date()).getTime();
483-
if(newMouseDownTime - gd._legendMouseDownTime < DBLCLICKDELAY) {
480+
if(newMouseDownTime - gd._legendMouseDownTime < doubleClickDelay) {
484481
// in a click train
485482
numClicks += 1;
486483
} else {
@@ -493,7 +490,7 @@ function setupTraceToggle(g, gd) {
493490
if(gd._dragged || gd._editing) return;
494491
var legend = gd._fullLayout.legend;
495492

496-
if((new Date()).getTime() - gd._legendMouseDownTime > DBLCLICKDELAY) {
493+
if((new Date()).getTime() - gd._legendMouseDownTime > doubleClickDelay) {
497494
numClicks = Math.max(numClicks - 1, 1);
498495
}
499496

src/constants/interactions.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ module.exports = {
1616
SHOW_PLACEHOLDER: 100,
1717
HIDE_PLACEHOLDER: 1000,
1818

19-
// ms between first mousedown and 2nd mouseup to constitute dblclick...
20-
// we don't seem to have access to the system setting
21-
DBLCLICKDELAY: 300,
22-
2319
// opacity dimming fraction for points that are not in selection
2420
DESELECTDIM: 0.2
2521
};

src/plots/cartesian/dragbox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ var SHOWZOOMOUTTIP = true;
5151
// ew - same for horizontal axis
5252
function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
5353
// mouseDown stores ms of first mousedown event in the last
54-
// DBLCLICKDELAY ms on the drag bars
54+
// `gd._context.doubleClickDelay` ms on the drag bars
5555
// numClicks stores how many mousedowns have been seen
56-
// within DBLCLICKDELAY so we can check for click or doubleclick events
56+
// within `gd._context.doubleClickDelay` so we can check for click or doubleclick events
5757
// dragged stores whether a drag has occurred, so we don't have to
5858
// redraw unnecessarily, ie if no move bigger than MINDRAG or MINZOOM px
5959
var zoomlayer = gd._fullLayout._zoomlayer;

test/jasmine/tests/annotations_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var Lib = require('@src/lib');
77
var Loggers = require('@src/lib/loggers');
88
var Axes = require('@src/plots/cartesian/axes');
99
var HOVERMINTIME = require('@src/components/fx').constants.HOVERMINTIME;
10-
var DBLCLICKDELAY = require('@src/constants/interactions').DBLCLICKDELAY;
10+
var DBLCLICKDELAY = require('@src/plot_api/plot_config').dfltConfig.doubleClickDelay;
1111

1212
var d3 = require('d3');
1313
var createGraphDiv = require('../assets/create_graph_div');

test/jasmine/tests/bar_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var Drawing = require('@src/components/drawing');
88
var Axes = require('@src/plots/cartesian/axes');
99

1010
var click = require('../assets/click');
11-
var DBLCLICKDELAY = require('../../../src/constants/interactions').DBLCLICKDELAY;
11+
var DBLCLICKDELAY = require('@src/plot_api/plot_config').dfltConfig.doubleClickDelay;
1212
var createGraphDiv = require('../assets/create_graph_div');
1313
var destroyGraphDiv = require('../assets/destroy_graph_div');
1414
var failTest = require('../assets/fail_test');

test/jasmine/tests/click_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var Plotly = require('@lib/index');
22
var Lib = require('@src/lib');
33
var Drawing = require('@src/components/drawing');
4-
var DBLCLICKDELAY = require('@src/constants/interactions').DBLCLICKDELAY;
4+
var DBLCLICKDELAY = require('@src/plot_api/plot_config').dfltConfig.doubleClickDelay;
55

66
var d3 = require('d3');
77
var createGraphDiv = require('../assets/create_graph_div');

test/jasmine/tests/geo_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var mouseEvent = require('../assets/mouse_event');
1717
var click = require('../assets/click');
1818
var drag = require('../assets/drag');
1919

20-
var DBLCLICKDELAY = require('@src/constants/interactions').DBLCLICKDELAY;
20+
var DBLCLICKDELAY = require('@src/plot_api/plot_config').dfltConfig.doubleClickDelay;
2121
var HOVERMINTIME = require('@src/components/fx').constants.HOVERMINTIME;
2222

2323
// use local topojson files

test/jasmine/tests/legend_scroll_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var Plotly = require('@lib/index');
22
var Lib = require('@src/lib');
33
var constants = require('@src/components/legend/constants');
4-
var DBLCLICKDELAY = require('@src/constants/interactions').DBLCLICKDELAY;
4+
var DBLCLICKDELAY = require('@src/plot_api/plot_config').dfltConfig.doubleClickDelay;
55

66
var d3 = require('d3');
77
var createGraph = require('../assets/create_graph_div');

test/jasmine/tests/legend_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var Plotly = require('@lib/index');
22
var Plots = require('@src/plots/plots');
33
var Lib = require('@src/lib');
4-
var DBLCLICKDELAY = require('@src/constants/interactions').DBLCLICKDELAY;
4+
var DBLCLICKDELAY = require('@src/plot_api/plot_config').dfltConfig.doubleClickDelay;
55

66
var Legend = require('@src/components/legend');
77
var getLegendData = require('@src/components/legend/get_legend_data');

0 commit comments

Comments
 (0)