feat(ags): add slide in anim for every notif

This commit is contained in:
matt1432 2023-09-14 16:42:39 -04:00
parent 4b3cdd82b9
commit bc3e5525c3
2 changed files with 36 additions and 14 deletions

View file

@ -27,23 +27,38 @@ export const Draggable = ({
let gesture = Gtk.GestureDrag.new(w); let gesture = Gtk.GestureDrag.new(w);
let leftAnim = 'transition: margin 0.5s ease, opacity 0.5s ease; ' +
'margin-left: -' + Number(maxOffset + endMargin) + 'px; ' +
'margin-right: ' + Number(maxOffset + endMargin) + 'px; ' +
'margin-bottom: -70px; margin-top: -70px; opacity: 0;';
let rightAnim = 'transition: margin 0.5s ease, opacity 0.5s ease; ' +
'margin-left: ' + Number(maxOffset + endMargin) + 'px; ' +
'margin-right: -' + Number(maxOffset + endMargin) + 'px; ' +
'margin-bottom: -70px; margin-top: -70px; opacity: 0;';
w.child = Box({ w.child = Box({
properties: [
['leftAnim', leftAnim],
['rightAnim', rightAnim],
],
children: [ children: [
...children, ...children,
child, child,
], ],
style: leftAnim,
connections: [ connections: [
[gesture, box => { [gesture, box => {
var offset = gesture.get_offset()[1]; var offset = gesture.get_offset()[1];
if (offset >= 0) { if (offset >= 0) {
box.setStyle('margin-left: ' + Number(offset + startMargin) + 'px; ' + box.setStyle('margin-left: ' + Number(offset + startMargin) + 'px; ' +
'margin-right: -' + Number(offset + startMargin) + 'px;'); 'margin-right: -' + Number(offset + startMargin) + 'px;');
} }
else { else {
offset = Math.abs(offset); offset = Math.abs(offset);
box.setStyle('margin-right: ' + Number(offset + startMargin) + 'px; ' + box.setStyle('margin-right: ' + Number(offset + startMargin) + 'px; ' +
'margin-left: -' + Number(offset + startMargin) + 'px;'); 'margin-left: -' + Number(offset + startMargin) + 'px;');
} }
@ -56,22 +71,18 @@ export const Draggable = ({
if (Math.abs(offset) > maxOffset) { if (Math.abs(offset) > maxOffset) {
if (offset > 0) { if (offset > 0) {
box.setStyle('transition: margin 0.5s ease, opacity 0.5s ease; ' + box.setStyle(rightAnim);
'margin-left: ' + Number(maxOffset + endMargin) + 'px; ' +
'margin-right: -' + Number(maxOffset + endMargin) + 'px; ' +
'margin-bottom: -70px; margin-top: -70px; opacity: 0;');
} }
else { else {
box.setStyle('transition: margin 0.5s ease, opacity 0.5s ease; ' + box.setStyle(leftAnim);
'margin-left: -' + Number(maxOffset + endMargin) + 'px; ' +
'margin-right: ' + Number(maxOffset + endMargin) + 'px; ' +
'margin-bottom: -70px; margin-top: -70px; opacity: 0;');
} }
setTimeout(command, 500); setTimeout(command, 500);
} }
else { else {
box.setStyle('transition: margin 0.5s ease; margin-left: ' + startMargin + 'px; ' + box.setStyle('transition: margin 0.5s ease, opacity 0.5s ease; ' +
'margin-right: ' + startMargin + 'px;'); 'margin-left: ' + startMargin + 'px; ' +
'margin-right: ' + startMargin + 'px; ' +
'margin-bottom: unset; margin-top: unset; opacity: 1;');
if (w.window) if (w.window)
w.window.set_cursor(Gdk.Cursor.new_from_name(display, 'grab')); w.window.set_cursor(Gdk.Cursor.new_from_name(display, 'grab'));
} }

View file

@ -1,7 +1,8 @@
import Notification from './base.js'; import Notification from './base.js';
const { Notifications } = ags.Service; const { Notifications } = ags.Service;
const { Box, Revealer, Window } = ags.Widget; const { Box, Revealer, Window } = ags.Widget;
const { timeout } = ags.Utils; const { timeout, interval } = ags.Utils;
const { source_remove } = imports.gi.GLib;
const Popups = () => Box({ const Popups = () => Box({
vertical: true, vertical: true,
@ -18,6 +19,7 @@ const Popups = () => Box({
box.get_parent().reveal_child = false; box.get_parent().reveal_child = false;
timeout(200, () => { timeout(200, () => {
source_remove(box._map.get(id)?.interval);
box._map.get(id)?.destroy(); box._map.get(id)?.destroy();
box._map.delete(id); box._map.delete(id);
}); });
@ -32,6 +34,15 @@ const Popups = () => Box({
timeout(10, () => { timeout(10, () => {
box.get_parent().revealChild = true; box.get_parent().revealChild = true;
}); });
box._map.get(id).interval = interval(4500, () => {
if (!box._map.get(id)._hovered) {
box._map.get(id).child.setStyle(box._map.get(id).child._leftAnim);
if (box._map.get(id)?.interval) {
source_remove(box._map.get(id)?.interval);
}
}
});
}], }],
], ],
connections: [ connections: [
@ -41,7 +52,7 @@ const Popups = () => Box({
], ],
}); });
const PopupList = ({ transition = 'slide_right' } = {}) => Box({ const PopupList = ({ transition = 'none' } = {}) => Box({
className: 'notifications-popup-list', className: 'notifications-popup-list',
style: 'padding: 1px', style: 'padding: 1px',
children: [ children: [