forked from d3/d3-brush
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configurable modifier keys, re issue d3#20
d3#20 Added modifier behavior "constants" that also hold the default key modifier. d3.brushForceNew (Meta key) <-- unsure on naming d3.brushFixSize (Space key) d3.brushFixCenter (Alt key) d3.brushFixSecondary (Shift key) Default modifier key code can be changed, or the behavior disabled, by calling ``` d3.brushFixSecondary.keyCode(newKeyCode); //change d3.brushFixCenter.keyCode(null); //disable ``` Default modifier key code can be retrieved by calling `.keyCode()` without arguments. Added `brush.keyModifier(behavior, keyCode)` method Modifier keys for an individual brush can be changed or disabled by calling ``` brush.keyModifier(d3.brushFixSecondary, keyCode); //change brush.keyModifier(d3.brushFixCenter, null); //disable ``` The current modifier key code can be retrieved by passing the behavior without an argument for key code. ``` const keyCode = brush.keyModifier(d3.brushFixSecondary); // keyCode === 16 ``` Note: Non-modifier keys can be set as the key code for brushFixCenter, but the behavior will only be applied/stopped for keydown/keyup while brushing is active, since the key code can't be mapped to one of the `modifierKey` properties on MouseEvent.
- Loading branch information
Showing
2 changed files
with
86 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters