make notif items also draggable to left

This commit is contained in:
end-4
2025-10-20 00:20:06 +02:00
parent 96605fb0fe
commit ba0f2248d8
2 changed files with 11 additions and 9 deletions
@@ -29,7 +29,7 @@ MouseArea { // Notification group area
property var parentDragDistance: qmlParent?.dragDistance property var parentDragDistance: qmlParent?.dragDistance
property var dragIndexDiff: Math.abs(parentDragIndex - index) property var dragIndexDiff: Math.abs(parentDragIndex - index)
property real xOffset: dragIndexDiff == 0 ? parentDragDistance : property real xOffset: dragIndexDiff == 0 ? parentDragDistance :
parentDragDistance > dragConfirmThreshold ? 0 : Math.abs(parentDragDistance) > dragConfirmThreshold ? 0 :
dragIndexDiff == 1 ? (parentDragDistance * 0.3) : dragIndexDiff == 1 ? (parentDragDistance * 0.3) :
dragIndexDiff == 2 ? (parentDragDistance * 0.1) : 0 dragIndexDiff == 2 ? (parentDragDistance * 0.1) : 0
@@ -24,10 +24,10 @@ Item { // Notification item area
property var parentDragIndex: qmlParent?.dragIndex ?? -1 property var parentDragIndex: qmlParent?.dragIndex ?? -1
property var parentDragDistance: qmlParent?.dragDistance ?? 0 property var parentDragDistance: qmlParent?.dragDistance ?? 0
property var dragIndexDiff: Math.abs(parentDragIndex - index) property var dragIndexDiff: Math.abs(parentDragIndex - index)
property real xOffset: dragIndexDiff == 0 ? Math.max(0, parentDragDistance) : property real xOffset: dragIndexDiff == 0 ? parentDragDistance :
parentDragDistance > dragConfirmThreshold ? 0 : Math.abs(parentDragDistance) > dragConfirmThreshold ? 0 :
dragIndexDiff == 1 ? Math.max(0, parentDragDistance * 0.3) : dragIndexDiff == 1 ? (parentDragDistance * 0.3) :
dragIndexDiff == 2 ? Math.max(0, parentDragDistance * 0.1) : 0 dragIndexDiff == 2 ? (parentDragDistance * 0.1) : 0
implicitHeight: background.implicitHeight implicitHeight: background.implicitHeight
@@ -53,9 +53,10 @@ Item { // Notification item area
return processedBody return processedBody
} }
function destroyWithAnimation() { function destroyWithAnimation(left = false) {
root.qmlParent.resetDrag() root.qmlParent.resetDrag()
background.anchors.leftMargin = background.anchors.leftMargin; // Break binding background.anchors.leftMargin = background.anchors.leftMargin; // Break binding
destroyAnimation.left = left;
destroyAnimation.running = true; destroyAnimation.running = true;
} }
@@ -67,12 +68,13 @@ Item { // Notification item area
SequentialAnimation { // Drag finish animation SequentialAnimation { // Drag finish animation
id: destroyAnimation id: destroyAnimation
property bool left: true
running: false running: false
NumberAnimation { NumberAnimation {
target: background.anchors target: background.anchors
property: "leftMargin" property: "leftMargin"
to: root.width + root.dismissOvershoot to: (root.width + root.dismissOvershoot) * (destroyAnimation.left ? -1 : 1)
duration: Appearance.animation.elementMove.duration duration: Appearance.animation.elementMove.duration
easing.type: Appearance.animation.elementMove.type easing.type: Appearance.animation.elementMove.type
easing.bezierCurve: Appearance.animation.elementMove.bezierCurve easing.bezierCurve: Appearance.animation.elementMove.bezierCurve
@@ -107,8 +109,8 @@ Item { // Notification item area
} }
onDragReleased: (diffX, diffY) => { onDragReleased: (diffX, diffY) => {
if (diffX > root.dragConfirmThreshold) if (Math.abs(diffX) > root.dragConfirmThreshold)
root.destroyWithAnimation(); root.destroyWithAnimation(diffX < 0);
else else
dragManager.resetDrag(); dragManager.resetDrag();
} }