From ba0f2248d8222b6d5b5d280c178d4e9d04673805 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Mon, 20 Oct 2025 00:20:06 +0200 Subject: [PATCH] make notif items also draggable to left --- .../common/widgets/NotificationGroup.qml | 2 +- .../common/widgets/NotificationItem.qml | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/dots/.config/quickshell/ii/modules/common/widgets/NotificationGroup.qml b/dots/.config/quickshell/ii/modules/common/widgets/NotificationGroup.qml index 1fa21a1a5..6e8e1cecc 100644 --- a/dots/.config/quickshell/ii/modules/common/widgets/NotificationGroup.qml +++ b/dots/.config/quickshell/ii/modules/common/widgets/NotificationGroup.qml @@ -29,7 +29,7 @@ MouseArea { // Notification group area property var parentDragDistance: qmlParent?.dragDistance property var dragIndexDiff: Math.abs(parentDragIndex - index) property real xOffset: dragIndexDiff == 0 ? parentDragDistance : - parentDragDistance > dragConfirmThreshold ? 0 : + Math.abs(parentDragDistance) > dragConfirmThreshold ? 0 : dragIndexDiff == 1 ? (parentDragDistance * 0.3) : dragIndexDiff == 2 ? (parentDragDistance * 0.1) : 0 diff --git a/dots/.config/quickshell/ii/modules/common/widgets/NotificationItem.qml b/dots/.config/quickshell/ii/modules/common/widgets/NotificationItem.qml index 0c0fa40a4..9175be110 100644 --- a/dots/.config/quickshell/ii/modules/common/widgets/NotificationItem.qml +++ b/dots/.config/quickshell/ii/modules/common/widgets/NotificationItem.qml @@ -24,10 +24,10 @@ Item { // Notification item area property var parentDragIndex: qmlParent?.dragIndex ?? -1 property var parentDragDistance: qmlParent?.dragDistance ?? 0 property var dragIndexDiff: Math.abs(parentDragIndex - index) - property real xOffset: dragIndexDiff == 0 ? Math.max(0, parentDragDistance) : - parentDragDistance > dragConfirmThreshold ? 0 : - dragIndexDiff == 1 ? Math.max(0, parentDragDistance * 0.3) : - dragIndexDiff == 2 ? Math.max(0, parentDragDistance * 0.1) : 0 + property real xOffset: dragIndexDiff == 0 ? parentDragDistance : + Math.abs(parentDragDistance) > dragConfirmThreshold ? 0 : + dragIndexDiff == 1 ? (parentDragDistance * 0.3) : + dragIndexDiff == 2 ? (parentDragDistance * 0.1) : 0 implicitHeight: background.implicitHeight @@ -53,9 +53,10 @@ Item { // Notification item area return processedBody } - function destroyWithAnimation() { + function destroyWithAnimation(left = false) { root.qmlParent.resetDrag() background.anchors.leftMargin = background.anchors.leftMargin; // Break binding + destroyAnimation.left = left; destroyAnimation.running = true; } @@ -67,12 +68,13 @@ Item { // Notification item area SequentialAnimation { // Drag finish animation id: destroyAnimation + property bool left: true running: false NumberAnimation { target: background.anchors property: "leftMargin" - to: root.width + root.dismissOvershoot + to: (root.width + root.dismissOvershoot) * (destroyAnimation.left ? -1 : 1) duration: Appearance.animation.elementMove.duration easing.type: Appearance.animation.elementMove.type easing.bezierCurve: Appearance.animation.elementMove.bezierCurve @@ -107,8 +109,8 @@ Item { // Notification item area } onDragReleased: (diffX, diffY) => { - if (diffX > root.dragConfirmThreshold) - root.destroyWithAnimation(); + if (Math.abs(diffX) > root.dragConfirmThreshold) + root.destroyWithAnimation(diffX < 0); else dragManager.resetDrag(); }