diff --git a/jfoenix/src/main/java/com/jfoenix/controls/JFXSnackbar.java b/jfoenix/src/main/java/com/jfoenix/controls/JFXSnackbar.java index f16e3cad..2503a5d2 100644 --- a/jfoenix/src/main/java/com/jfoenix/controls/JFXSnackbar.java +++ b/jfoenix/src/main/java/com/jfoenix/controls/JFXSnackbar.java @@ -244,13 +244,15 @@ private Timeline getTimeline(Duration timeout) { pauseTransition = Duration.INDEFINITE.equals(timeout) ? null : new PauseTransition(timeout); if (pauseTransition != null) { animation.setOnFinished(finish -> { - pauseTransition.setOnFinished(done -> { - pauseTransition = null; - eventsSet.remove(currentEvent); - currentEvent = eventQueue.peek(); - close(); - }); - pauseTransition.play(); + if (pauseTransition != null) { + pauseTransition.setOnFinished(done -> { + pauseTransition = null; + eventsSet.remove(currentEvent); + currentEvent = eventQueue.peek(); + close(); + }); + pauseTransition.play(); + } }); } return animation; @@ -261,6 +263,10 @@ public void close() { openAnimation.stop(); } if (this.isVisible()) { + if (pauseTransition != null) { + pauseTransition.stop(); + pauseTransition = null; + } Timeline closeAnimation = new Timeline( new KeyFrame( Duration.ZERO,