HShortcutHandler & HShortcut components

Provide more powerful shortcuts handling than what's available with
QML's Shortcut component, notably being able to react differently to key
presses, releases and auto-repeats.
This commit is contained in:
miruka
2019-08-22 13:03:26 -04:00
parent 3749d1e135
commit 8de26c11a1
9 changed files with 118 additions and 60 deletions

View File

@@ -162,3 +162,15 @@ function getItem(array, mainKey, value) {
}
return undefined
}
function smartVerticalFlick(flickTarget, baseVelocity, fastMultiply=3) {
if (! flickTarget.interactive) { return }
baseVelocity = -baseVelocity
let vel = -flickTarget.verticalVelocity
let fast = (baseVelocity < 0 && vel < baseVelocity / 2) ||
(baseVelocity > 0 && vel > baseVelocity / 2)
flickTarget.flick(0, baseVelocity * (fast ? fastMultiply : 1))
}