make songsel fast + add mousewheel scrolling

This commit is contained in:
Bui 2022-02-16 13:13:52 +00:00
parent 714a0302ec
commit d85f8909d7

View File

@ -290,10 +290,12 @@ class SongSelect{
focused: true focused: true
} }
this.songSelecting = { this.songSelecting = {
speed: 800, speed: 200,
resize: 0.3, resize: 0.3,
scrollDelay: 0.1 scrollDelay: 0.1
} }
this.wheelScrolls = 0
this.wheelTimer = 0
this.startPreview(true) this.startPreview(true)
@ -340,6 +342,8 @@ class SongSelect{
pageEvents.add(this.touchFullBtn, "touchend", toggleFullscreen) pageEvents.add(this.touchFullBtn, "touchend", toggleFullscreen)
} }
pageEvents.add(this.canvas, "wheel", this.mouseWheel.bind(this))
this.selectable = document.getElementById("song-sel-selectable") this.selectable = document.getElementById("song-sel-selectable")
this.selectableText = "" this.selectableText = ""
@ -503,6 +507,17 @@ class SongSelect{
touchEnd(event){ touchEnd(event){
event.preventDefault() event.preventDefault()
} }
mouseWheel(event){
if(this.state.screen === "song"){
this.wheelTimer = this.getMS()
if(event.deltaY < 0) {
this.wheelScrolls++
}else if(event.deltaY > 0){
this.wheelScrolls--
}
}
}
mouseMove(event){ mouseMove(event){
var mouse = this.mouseOffset(event.offsetX, event.offsetY) var mouse = this.mouseOffset(event.offsetX, event.offsetY)
var moveTo = null var moveTo = null
@ -892,13 +907,18 @@ class SongSelect{
for(var key in this.pressedKeys){ for(var key in this.pressedKeys){
if(this.pressedKeys[key]){ if(this.pressedKeys[key]){
if(ms >= this.pressedKeys[key] + 50){ if(ms >= this.pressedKeys[key] + (this.state.screen === "song" && (key === "right" || key === "left") ? 20 : 50)){
this.keyPress(true, key, null, true) this.keyPress(true, key, null, true)
this.pressedKeys[key] = ms this.pressedKeys[key] = ms
} }
} }
} }
if(this.wheelScrolls !== 0 && ms >= this.wheelTimer + 20) {
this.moveToSong(this.wheelScrolls)
this.wheelScrolls = 0
}
if(!this.redrawRunning){ if(!this.redrawRunning){
return return
} }