forked from Shinonome/dots-hyprland
notifications: fix clearing animation
This commit is contained in:
@@ -453,7 +453,7 @@ export default ({
|
|||||||
}, wholeThing);
|
}, wholeThing);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
self.setCss(`transition: margin 200ms cubic-bezier(0.05, 0.7, 0.1, 1), opacity 200ms cubic-bezier(0.05, 0.7, 0.1, 1);
|
self.setCss(`transition: ${userOptions.animations.durationSmall}ms cubic-bezier(0.05, 0.7, 0.1, 1), opacity ${userOptions.animations.durationSmall}ms cubic-bezier(0.05, 0.7, 0.1, 1);
|
||||||
margin-left: ${startMargin}px;
|
margin-left: ${startMargin}px;
|
||||||
margin-right: ${startMargin}px;
|
margin-right: ${startMargin}px;
|
||||||
margin-bottom: unset; margin-top: unset;
|
margin-bottom: unset; margin-top: unset;
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import Notification from '../../.commonwidgets/notification.js';
|
|||||||
import { ConfigToggle } from '../../.commonwidgets/configwidgets.js';
|
import { ConfigToggle } from '../../.commonwidgets/configwidgets.js';
|
||||||
|
|
||||||
export default (props) => {
|
export default (props) => {
|
||||||
|
let previousLength;
|
||||||
|
let clearing = false;
|
||||||
|
|
||||||
const notifEmptyContent = Box({
|
const notifEmptyContent = Box({
|
||||||
homogeneous: true,
|
homogeneous: true,
|
||||||
children: [Box({
|
children: [Box({
|
||||||
@@ -86,15 +89,6 @@ export default (props) => {
|
|||||||
Notifications.dnd = !Notifications.dnd;
|
Notifications.dnd = !Notifications.dnd;
|
||||||
self.toggleClassName('notif-listaction-btn-enabled', Notifications.dnd);
|
self.toggleClassName('notif-listaction-btn-enabled', Notifications.dnd);
|
||||||
});
|
});
|
||||||
// const silenceToggle = ConfigToggle({
|
|
||||||
// expandWidget: false,
|
|
||||||
// icon: 'do_not_disturb_on',
|
|
||||||
// name: 'Do Not Disturb',
|
|
||||||
// initValue: false,
|
|
||||||
// onChange: (self, newValue) => {
|
|
||||||
// Notifications.dnd = newValue;
|
|
||||||
// },
|
|
||||||
// })
|
|
||||||
const clearButton = Revealer({
|
const clearButton = Revealer({
|
||||||
transition: 'slide_right',
|
transition: 'slide_right',
|
||||||
transitionDuration: userOptions.animations.durationSmall,
|
transitionDuration: userOptions.animations.durationSmall,
|
||||||
@@ -102,6 +96,7 @@ export default (props) => {
|
|||||||
self.revealChild = Notifications.notifications.length > 0;
|
self.revealChild = Notifications.notifications.length > 0;
|
||||||
}),
|
}),
|
||||||
child: ListActionButton('clear_all', getString('Clear'), () => {
|
child: ListActionButton('clear_all', getString('Clear'), () => {
|
||||||
|
clearing = true;
|
||||||
Notifications.clear();
|
Notifications.clear();
|
||||||
const kids = notificationList.get_children();
|
const kids = notificationList.get_children();
|
||||||
for (let i = 0; i < kids.length; i++) {
|
for (let i = 0; i < kids.length; i++) {
|
||||||
@@ -134,8 +129,6 @@ export default (props) => {
|
|||||||
children: [
|
children: [
|
||||||
notifCount,
|
notifCount,
|
||||||
silenceButton,
|
silenceButton,
|
||||||
// silenceToggle,
|
|
||||||
// Box({ hexpand: true }),
|
|
||||||
clearButton,
|
clearButton,
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -160,9 +153,21 @@ export default (props) => {
|
|||||||
'empty': notifEmptyContent,
|
'empty': notifEmptyContent,
|
||||||
'list': notifList,
|
'list': notifList,
|
||||||
},
|
},
|
||||||
setup: (self) => self.hook(Notifications, (self) => {
|
setup: (self) => {
|
||||||
self.shown = (Notifications.notifications.length > 0 ? 'list' : 'empty')
|
previousLength = Notifications.notifications.length;
|
||||||
}),
|
self.hook(Notifications, (self) => {
|
||||||
|
if (Notifications.notifications.length > 0) {
|
||||||
|
self.shown = 'list';
|
||||||
|
if (!clearing) previousLength = Notifications.notifications.length;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Utils.timeout(userOptions.animations.choreographyDelay * previousLength, () => {
|
||||||
|
clearing = false;
|
||||||
|
if (Notifications.notifications.length == 0) self.shown = 'empty';
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return Box({
|
return Box({
|
||||||
...props,
|
...props,
|
||||||
|
|||||||
Reference in New Issue
Block a user