ClickRepeater
A helper class, which, when applied to an element means that a mousedown and hold on that element will, after a configured delay, begin autorepeating click events on that element, starting at a rate of startRate clicks per second, and over accelerateDuration milliseconds, accelerate to firing clicks at endRate times per second.
An example of this is used by the NumberField's spinner triggers.
const repeater = new ClickRepeater({
element : document.getElementById('increment-btn'),
delay : 400,
endRate : 10
});
Useful configs
| Config | Description |
|---|---|
| element | The element on which to fire repeating click events |
| delay | Milliseconds to wait before repeating starts |
| startRate | Initial clicks per second |
| endRate | Maximum clicks per second after acceleration |
| accelerateDuration | Time in ms to ramp from start rate to end rate |
See also
- NumberField - Uses ClickRepeater for spinner triggers
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
How long in milliSeconds to pause before starting the click repeats.
-
A query selector which specifies subtargets of this ClickRepeater's element which act as the click auto repeat event targets.
-
The element on which to fire autorepeating
clickevents when the mouse is held down. -
Clicks per second to fire at top speed, after accelerating over the accelerateDuration
-
Clicks per second to start firing after the initial delay