Fix text selection start drag delay

This commit is contained in:
miruka
2019-09-11 15:25:57 -04:00
parent b17a958906
commit d998b471f0
3 changed files with 47 additions and 32 deletions

View File

@@ -13,23 +13,23 @@ Rectangle {
anchors.fill: parent
reversed: eventList.verticalLayoutDirection == ListView.BottomToTop
onDragPositionChanged: {
let left = dragPoint.pressedButtons & Qt.LeftButton
let vel = dragPoint.velocity.y
DragHandler {
target: null
onActiveChanged: if (! active) dragFlicker.speed = 0
onCentroidChanged: {
let left = centroid.pressedButtons & Qt.LeftButton
let vel = centroid.velocity.y
let pos = centroid.position.y
let dist = Math.min(selectableLabelContainer.height / 4, 50)
let boost = 20 * (pos < dist ? -pos : -(height - pos))
let boost = 20 * (
dragPosition.y < 50 ?
-dragPosition.y : -(height - dragPosition.y)
)
dragFlicker.speed =
dragPosition.x == 0 && dragPosition.y == 0 ? 0 :
left && vel && dragPosition.y < 50 ? 1000 + boost:
left && vel && dragPosition.y > height - 50 ? -1000 + -boost :
0
dragFlicker.speed =
left && vel && pos < dist ? 1000 + boost :
left && vel && pos > height - dist ? -1000 + -boost :
0
}
}
Timer {
id: dragFlicker
interval: 100