Skip to content

Commit

Permalink
add a small (configurable) delay for when notification is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Oct 1, 2024
1 parent f848635 commit a1b1215
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions haxe/ui/notifications/NotificationManager.hx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class NotificationManager extends EventDispatcher<NotificationEvent> {
private static var DEFAULT_EXPIRY:Int = 3000;

public var maxNotifications:Int = -1;
public var notificationDisplayDelayMs:Int = 50;
public var animationFn:Array<Notification>->Array<AnimationBuilder> = AnimateFromBottom;

private var _timer:Timer = null;
Expand Down Expand Up @@ -79,12 +80,14 @@ class NotificationManager extends EventDispatcher<NotificationEvent> {
var notification = new Notification();
notification.registerEvent(UIEvent.DESTROY, onNotificationDestroyed);
notification.notificationData = notificationData;
if (!_isAnimating) {
pushNotification(notification);
} else {
_addQueue.push(notification);
startTimer();
}
Timer.delay(function() {
if (!_isAnimating) {
pushNotification(notification);
} else {
_addQueue.push(notification);
startTimer();
}
}, notificationDisplayDelayMs);

return notification;
}
Expand Down

0 comments on commit a1b1215

Please sign in to comment.