quickshell-toki-night/custom/CustomMouseArea.qml

22 lines
587 B
QML

import QtQuick
MouseArea {
property int scrollAccumulatedY: 0
property int scrollThreshold: 160
function onWheel(event: WheelEvent): void {
}
onWheel: event => {
// Update accumulated scroll
if (Math.sign(event.angleDelta.y) !== Math.sign(scrollAccumulatedY))
scrollAccumulatedY = 0;
scrollAccumulatedY += event.angleDelta.y;
// Trigger handler and reset if above threshold
if (Math.abs(scrollAccumulatedY) >= scrollThreshold) {
onWheel(event);
scrollAccumulatedY = 0;
}
}
}