Add scroll to top/bottom keybinds
This commit is contained in:
parent
6a540f6397
commit
70b82b7b59
|
@ -115,6 +115,10 @@ class UISettings(JSONConfigFile):
|
||||||
"scrollDown": ["Alt+Down", "Alt+J"],
|
"scrollDown": ["Alt+Down", "Alt+J"],
|
||||||
"scrollPageUp": ["Alt+Ctrl+Up", "Alt+Ctrl+K", "PageUp"],
|
"scrollPageUp": ["Alt+Ctrl+Up", "Alt+Ctrl+K", "PageUp"],
|
||||||
"scrollPageDown": ["Alt+Ctrl+Down", "Alt+Ctrl+J", "PageDown"],
|
"scrollPageDown": ["Alt+Ctrl+Down", "Alt+Ctrl+J", "PageDown"],
|
||||||
|
"scrollToTop":
|
||||||
|
["Alt+Ctrl+Shift+Up", "Alt+Ctrl+Shift+K", "Home"],
|
||||||
|
"scrollToBottom":
|
||||||
|
["Alt+Ctrl+Shift+Down", "Alt+Ctrl+Shift+J", "End"],
|
||||||
|
|
||||||
"focusSidePane": ["Alt+S", "Ctrl+S"],
|
"focusSidePane": ["Alt+S", "Ctrl+S"],
|
||||||
"clearRoomFilter": ["Alt+Shift+S", "Ctrl+Shift+S"],
|
"clearRoomFilter": ["Alt+Shift+S", "Ctrl+Shift+S"],
|
||||||
|
|
|
@ -48,6 +48,18 @@ HShortcutHandler {
|
||||||
onHeld: pressed(event)
|
onHeld: pressed(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HShortcut {
|
||||||
|
sequences: settings.keys.scrollToTop
|
||||||
|
onPressed: Utils.flickToTop(flickTarget)
|
||||||
|
onHeld: pressed(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
HShortcut {
|
||||||
|
sequences: settings.keys.scrollToBottom
|
||||||
|
onPressed: Utils.flickToBottom(flickTarget)
|
||||||
|
onHeld: pressed(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// SidePane
|
// SidePane
|
||||||
|
|
||||||
|
|
|
@ -169,13 +169,31 @@ function getItem(array, mainKey, value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function smartVerticalFlick(flickTarget, baseVelocity, fastMultiply=3) {
|
function smartVerticalFlick(flickable, baseVelocity, fastMultiply=3) {
|
||||||
if (! flickTarget.interactive) { return }
|
if (! flickable.interactive) { return }
|
||||||
|
|
||||||
baseVelocity = -baseVelocity
|
baseVelocity = -baseVelocity
|
||||||
let vel = -flickTarget.verticalVelocity
|
let vel = -flickable.verticalVelocity
|
||||||
let fast = (baseVelocity < 0 && vel < baseVelocity / 2) ||
|
let fast = (baseVelocity < 0 && vel < baseVelocity / 2) ||
|
||||||
(baseVelocity > 0 && vel > baseVelocity / 2)
|
(baseVelocity > 0 && vel > baseVelocity / 2)
|
||||||
|
|
||||||
flickTarget.flick(0, baseVelocity * (fast ? fastMultiply : 1))
|
flickable.flick(0, baseVelocity * (fast ? fastMultiply : 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
function flickToTop(flickable) {
|
||||||
|
if (! flickable.interactive) return
|
||||||
|
if (flickable.visibleArea.yPosition < 0) return
|
||||||
|
|
||||||
|
flickable.contentY -= flickable.contentHeight
|
||||||
|
flickable.returnToBounds()
|
||||||
|
flickable.flick(0, -100) // Force the delegates to load
|
||||||
|
}
|
||||||
|
|
||||||
|
function flickToBottom(flickable) {
|
||||||
|
if (! flickable.interactive) return
|
||||||
|
if (flickable.visibleArea.yPosition < 0) return
|
||||||
|
|
||||||
|
flickable.contentY = flickTarget.contentHeight - flickTarget.height
|
||||||
|
flickable.returnToBounds()
|
||||||
|
flickable.flick(0, 100)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user