Skip to content

Commit b6d64be

Browse files
committed
alter argument order of throttle.throttle
and beef up its docstring
1 parent 6da3cfa commit b6d64be

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/components/fx/hover.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ exports.hover = function hover(gd, evt, subplot, noHoverEvent) {
7070
gd = Lib.getGraphDiv(gd);
7171

7272
Lib.throttle(
73-
function() { _hover(gd, evt, subplot, noHoverEvent); },
73+
gd._fullLayout._uid + constants.HOVERID,
7474
constants.HOVERMINTIME,
75-
gd._fullLayout._uid + constants.HOVERID
75+
function() { _hover(gd, evt, subplot, noHoverEvent); }
7676
);
7777
};
7878

src/lib/throttle.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ var timerCache = {};
1818
* So the first and last events in a train are always executed (eventually)
1919
* but some of the events in the middle can be dropped.
2020
*
21-
* @param {function} callback: the function to throttle
2221
* @param {string} id: an identifier to mark events to throttle together
2322
* @param {number} minInterval: minimum time, in milliseconds, between
2423
* invocations of `callback`
24+
* @param {function} callback: the function to throttle. `callback` itself
25+
* should be a purely synchronous function.
2526
*/
26-
exports.throttle = function throttle(callback, minInterval, id) {
27+
exports.throttle = function throttle(id, minInterval, callback) {
2728
var cache = timerCache[id];
2829
var now = Date.now();
2930

src/plots/cartesian/select.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
184184
}
185185

186186
throttle.throttle(
187+
throttleID,
188+
constants.SELECTDELAY,
187189
function() {
188190
selection = [];
189191
for(i = 0; i < searchTraces.length; i++) {
@@ -202,9 +204,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
202204
eventData = {points: selection};
203205
fillRangeItems(eventData, poly, pts);
204206
dragOptions.gd.emit('plotly_selecting', eventData);
205-
},
206-
constants.SELECTDELAY,
207-
throttleID
207+
}
208208
);
209209
};
210210

0 commit comments

Comments
 (0)