1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-27 05:49:07 +02:00

Replace event.which with event.key and event.button

This commit is contained in:
Tanguy Krotoff
2020-04-15 16:52:18 +02:00
committed by XhmikosR
parent 8547ab149a
commit dcd99aa7d1
7 changed files with 100 additions and 110 deletions

View File

@@ -33,8 +33,8 @@ const DATA_KEY = 'bs.carousel'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
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 ARROW_LEFT_KEY = 'ArrowLeft'
const ARROW_RIGHT_KEY = 'ArrowRight'
const TOUCHEVENT_COMPAT_WAIT = 500 // Time for mouse compat events to fire after touch
const SWIPE_THRESHOLD = 40
@@ -342,12 +342,12 @@ class Carousel {
return
}
switch (event.which) {
case ARROW_LEFT_KEYCODE:
switch (event.key) {
case ARROW_LEFT_KEY:
event.preventDefault()
this.prev()
break
case ARROW_RIGHT_KEYCODE:
case ARROW_RIGHT_KEY:
event.preventDefault()
this.next()
break