forked from Shinonome/dots-hyprland
36 lines
1.4 KiB
QML
36 lines
1.4 KiB
QML
import QtQuick
|
|
import qs.modules.common
|
|
|
|
Flickable {
|
|
id: root
|
|
maximumFlickVelocity: 3500
|
|
boundsBehavior: Flickable.DragOverBounds
|
|
|
|
property real touchpadScrollFactor: Config?.options.interactions.scrolling.touchpadScrollFactor ?? 100
|
|
property real mouseScrollFactor: Config?.options.interactions.scrolling.mouseScrollFactor ?? 50
|
|
property real mouseScrollDeltaThreshold: Config?.options.interactions.scrolling.mouseScrollDeltaThreshold ?? 120
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
acceptedButtons: Qt.NoButton
|
|
onWheel: function(wheelEvent) {
|
|
const delta = wheelEvent.angleDelta.y / root.mouseScrollDeltaThreshold;
|
|
// The angleDelta.y of a touchpad is usually small and continuous,
|
|
// while that of a mouse wheel is typically in multiples of ±120.
|
|
var scrollFactor = Math.abs(wheelEvent.angleDelta.y) >= root.mouseScrollDeltaThreshold ? root.mouseScrollFactor : root.touchpadScrollFactor;
|
|
var targetY = root.contentY - delta * scrollFactor;
|
|
targetY = Math.max(0, Math.min(targetY, root.contentHeight - root.height));
|
|
root.contentY = targetY;
|
|
}
|
|
}
|
|
|
|
Behavior on contentY {
|
|
NumberAnimation {
|
|
id: scrollAnim
|
|
duration: Appearance.animation.scroll.duration
|
|
easing.type: Appearance.animation.scroll.type
|
|
easing.bezierCurve: Appearance.animation.scroll.bezierCurve
|
|
}
|
|
}
|
|
}
|