diff --git a/haxe/ui/notifications/NotificationManager.hx b/haxe/ui/notifications/NotificationManager.hx index 1f4cd8f63..8a3335b8b 100644 --- a/haxe/ui/notifications/NotificationManager.hx +++ b/haxe/ui/notifications/NotificationManager.hx @@ -77,6 +77,7 @@ class NotificationManager extends EventDispatcher { } var notification = new Notification(); + notification.registerEvent(UIEvent.DESTROY, onNotificationDestroyed); notification.notificationData = notificationData; if (!_isAnimating) { pushNotification(notification); @@ -102,6 +103,15 @@ class NotificationManager extends EventDispatcher { popNotification(notification); } + private function onNotificationDestroyed(event:UIEvent) { + // notifications could actually be destroyed in a variety of ways (like removing directly from Screen) + // if that is the case, lets clean up after ourselves and reset our internal state (if required) + _currentNotifications.remove(cast event.target); + if (_currentNotifications.length == 0) { + _isAnimating = false; + } + } + public function clearNotifications():Void { for (notification in _currentNotifications) { removeNotification(notification);