notifs: fix opening anim when spam notifs

No open/close state, just animate height
This commit is contained in:
2 * r + 2 * t 2025-05-29 23:37:02 +08:00
parent e8a2d861fb
commit dc1b01ccd3
4 changed files with 36 additions and 60 deletions

View file

@ -105,7 +105,6 @@ Variants {
id: visibilities id: visibilities
property bool osd property bool osd
property bool notifications: Notifs.popups.length > 0
property bool session property bool session
property bool launcher property bool launcher
property bool dashboard property bool dashboard

View file

@ -40,8 +40,6 @@ Item {
Notifications.Wrapper { Notifications.Wrapper {
id: notifications id: notifications
visibility: root.visibilities.notifications
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
} }

View file

@ -10,34 +10,19 @@ Item {
readonly property int padding: Appearance.padding.large readonly property int padding: Appearance.padding.large
anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right anchors.right: parent.right
implicitWidth: NotifsConfig.sizes.width + root.padding * 2 implicitWidth: NotifsConfig.sizes.width + padding * 2
implicitHeight: list.implicitHeight + root.padding * 2
ClippingWrapperRectangle {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: root.padding
color: "transparent"
radius: Appearance.rounding.normal
ListView {
id: list
model: ScriptModel {
values: [...Notifs.popups].reverse()
}
anchors.fill: parent
implicitHeight: { implicitHeight: {
let height = (count - 1) * spacing; const count = list.count;
if (count === 0)
return 0;
let height = (count - 1) * list.spacing;
for (let i = 0; i < count; i++) for (let i = 0; i < count; i++)
height += itemAtIndex(i)?.nonAnimHeight ?? 0; height += list.itemAtIndex(i)?.nonAnimHeight ?? 0;
const screen = QsWindow.window?.screen; const screen = QsWindow.window?.screen;
const visibilities = Visibilities.screens[screen]; const visibilities = Visibilities.screens[screen];
@ -56,9 +41,25 @@ Item {
} }
} }
return Math.max(61, Math.min((screen?.height ?? 0) - root.padding * 2 - BorderConfig.thickness * 2, height)); return Math.min((screen?.height ?? 0) - BorderConfig.thickness * 2, height + padding * 2);
} }
ClippingWrapperRectangle {
anchors.fill: parent
anchors.margins: root.padding
color: "transparent"
radius: Appearance.rounding.normal
ListView {
id: list
model: ScriptModel {
values: [...Notifs.popups].reverse()
}
anchors.fill: parent
orientation: Qt.Vertical orientation: Qt.Vertical
spacing: Appearance.spacing.smaller spacing: Appearance.spacing.smaller
cacheBuffer: QsWindow.window?.screen.height ?? 0 cacheBuffer: QsWindow.window?.screen.height ?? 0
@ -92,12 +93,12 @@ Item {
property: "y" property: "y"
} }
} }
}
}
Behavior on implicitHeight { Behavior on implicitHeight {
Anim {} Anim {}
} }
}
}
component Anim: NumberAnimation { component Anim: NumberAnimation {
duration: Appearance.anim.durations.expressiveDefaultSpatial duration: Appearance.anim.durations.expressiveDefaultSpatial

View file

@ -1,35 +1,13 @@
import "root:/config" import "root:/config"
import Quickshell
import QtQuick import QtQuick
Item { Item {
id: root id: root
required property bool visibility
visible: height > 0 visible: height > 0
implicitHeight: 0 implicitHeight: content.implicitHeight
implicitWidth: content.implicitWidth + BorderConfig.rounding implicitWidth: content.implicitWidth + BorderConfig.rounding
states: State {
name: "visible"
when: root.visibility
PropertyChanges {
root.implicitHeight: content.implicitHeight
}
}
transitions: Transition {
NumberAnimation {
target: root
property: "implicitHeight"
duration: Appearance.anim.durations.expressiveDefaultSpatial
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
}
}
Content { Content {
id: content id: content
} }