From bc3e5525c365be05d1f3acc0f6baf7bb10be67f4 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Thu, 14 Sep 2023 16:42:39 -0400 Subject: [PATCH] feat(ags): add slide in anim for every notif --- config/ags/js/misc/drag.js | 35 ++++++++++++++++++---------- config/ags/js/notifications/popup.js | 15 ++++++++++-- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/config/ags/js/misc/drag.js b/config/ags/js/misc/drag.js index fb6225d..19332aa 100644 --- a/config/ags/js/misc/drag.js +++ b/config/ags/js/misc/drag.js @@ -27,23 +27,38 @@ export const Draggable = ({ 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({ + properties: [ + ['leftAnim', leftAnim], + ['rightAnim', rightAnim], + ], children: [ ...children, child, ], + style: leftAnim, connections: [ [gesture, box => { var offset = gesture.get_offset()[1]; 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;'); } else { 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;'); } @@ -56,22 +71,18 @@ export const Draggable = ({ if (Math.abs(offset) > maxOffset) { if (offset > 0) { - box.setStyle('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;'); + box.setStyle(rightAnim); } else { - box.setStyle('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;'); + box.setStyle(leftAnim); } setTimeout(command, 500); } else { - box.setStyle('transition: margin 0.5s ease; margin-left: ' + startMargin + 'px; ' + - 'margin-right: ' + startMargin + 'px;'); + box.setStyle('transition: margin 0.5s ease, opacity 0.5s ease; ' + + 'margin-left: ' + startMargin + 'px; ' + + 'margin-right: ' + startMargin + 'px; ' + + 'margin-bottom: unset; margin-top: unset; opacity: 1;'); if (w.window) w.window.set_cursor(Gdk.Cursor.new_from_name(display, 'grab')); } diff --git a/config/ags/js/notifications/popup.js b/config/ags/js/notifications/popup.js index a8f5f65..7854036 100644 --- a/config/ags/js/notifications/popup.js +++ b/config/ags/js/notifications/popup.js @@ -1,7 +1,8 @@ import Notification from './base.js'; const { Notifications } = ags.Service; const { Box, Revealer, Window } = ags.Widget; -const { timeout } = ags.Utils; +const { timeout, interval } = ags.Utils; +const { source_remove } = imports.gi.GLib; const Popups = () => Box({ vertical: true, @@ -18,6 +19,7 @@ const Popups = () => Box({ box.get_parent().reveal_child = false; timeout(200, () => { + source_remove(box._map.get(id)?.interval); box._map.get(id)?.destroy(); box._map.delete(id); }); @@ -32,6 +34,15 @@ const Popups = () => Box({ timeout(10, () => { 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: [ @@ -41,7 +52,7 @@ const Popups = () => Box({ ], }); -const PopupList = ({ transition = 'slide_right' } = {}) => Box({ +const PopupList = ({ transition = 'none' } = {}) => Box({ className: 'notifications-popup-list', style: 'padding: 1px', children: [