diff options
| author | Chris Rebert <[email protected]> | 2016-05-30 23:42:00 -0700 |
|---|---|---|
| committer | Chris Rebert <[email protected]> | 2016-05-30 23:42:00 -0700 |
| commit | 5a35ad6d74c8d9e5aa99a1fc255300a8fd2ac0b4 (patch) | |
| tree | 8243d9d8cea3f86624462fc052c8957d7dc6ae6f /js/src/carousel.js | |
| parent | 301dc70e1b04fdb70ac8e83a6906b6b27d7d2235 (diff) | |
| download | bootstrap-5a35ad6d74c8d9e5aa99a1fc255300a8fd2ac0b4.tar.xz bootstrap-5a35ad6d74c8d9e5aa99a1fc255300a8fd2ac0b4.zip | |
Use named constants for magic numbers (#19992)
Mostly KeyboardEvent.which and MouseEvent.which values.
[skip validator]
Diffstat (limited to 'js/src/carousel.js')
| -rw-r--r-- | js/src/carousel.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js index 34cab4391..f990c699a 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -24,6 +24,8 @@ const Carousel = (($) => { const DATA_API_KEY = '.data-api' const JQUERY_NO_CONFLICT = $.fn[NAME] const TRANSITION_DURATION = 600 + const ARROW_LEFT_KEYCODE = 37 // KeyboardEvent.which value for left arrow key + const ARROW_RIGHT_KEYCODE = 39 // KeyboardEvent.which value for right arrow key const Default = { interval : 5000, @@ -236,8 +238,8 @@ const Carousel = (($) => { } switch (event.which) { - case 37: this.prev(); break - case 39: this.next(); break + case ARROW_LEFT_KEYCODE: this.prev(); break + case ARROW_RIGHT_KEYCODE: this.next(); break default: return } } |
