Skip to content

Commit ca7e1b2

Browse files
committed
don't debounce by default
1 parent da6b0c8 commit ca7e1b2

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

R/highlight.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
#' @param opacityDim a number between 0 and 1 used to reduce the
4444
#' opacity of non-selected traces (by multiplying with the existing opacity).
4545
#' @param selected attributes of the selection, see [attrs_selected()].
46-
#' @param debounce amount of time to wait before firing an event (in milliseconds).
47-
#' This is especially useful when `on = "plotly_hover"` to avoid firing too many events
46+
#' @param debounce amount of time to wait before firing an event (in milliseconds).
47+
#' The default of 0 means do not debounce at all.
48+
#' Debouncing is mainly useful when `on = "plotly_hover"` to avoid firing too many events
4849
#' when users clickly move the mouse over relevant graphical marks.
4950
#' @param ... currently not supported.
5051
#' @export
@@ -83,7 +84,7 @@ highlight <- function(p, on = "plotly_click", off,
8384
dynamic = FALSE, color = NULL,
8485
selectize = FALSE, defaultValues = NULL,
8586
opacityDim = getOption("opacityDim", 0.2),
86-
selected = attrs_selected(), debounce = 1,
87+
selected = attrs_selected(), debounce = 0,
8788
...) {
8889

8990
# currently ... is not-supported and will catch

inst/htmlwidgets/plotly.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,10 @@ HTMLWidgets.widget({
471471
}
472472
}
473473
};
474-
475-
graphDiv.on(x.highlight.on, debounce(turnOn, x.highlight.debounce));
474+
if (x.highlight.debounce > 0) {
475+
turnOn = debounce(turnOn, x.highlight.debounce);
476+
}
477+
graphDiv.on(x.highlight.on, turnOn);
476478

477479
graphDiv.on(x.highlight.off, function turnOff(e) {
478480
// remove any visual clues

man/highlight.Rd

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plot_ly.Rd

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)