-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathdouble_click.js
28 lines (26 loc) · 956 Bytes
/
double_click.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var click = require('./click');
var getNodeCoords = require('./get_node_coords');
var DBLCLICKDELAY = require('../../../src/plot_api/plot_config').dfltConfig.doubleClickDelay;
/*
* Double click on a point.
* You can either specify x,y as pixels, or
* you can specify node and optionally an edge ('n', 'se', 'w' etc)
* to grab it by an edge or corner (otherwise the middle is used).
* You can also pass options for the underlying click, e.g.
* to specify modifier keys. See `click` function
* for more info.
*/
module.exports = function doubleClick(x, y, clickOpts) {
if(typeof x === 'object') {
var coords = getNodeCoords(x, y);
x = coords.x;
y = coords.y;
}
return new Promise(function(resolve) {
click(x, y, clickOpts);
setTimeout(function() {
click(x, y, clickOpts);
setTimeout(function() { resolve(); }, DBLCLICKDELAY / 2);
}, DBLCLICKDELAY / 2);
});
};