diff options
author | Jouni Koivuviita <jouni@vaadin.com> | 2014-08-07 17:22:14 +0300 |
---|---|---|
committer | Jouni Koivuviita <jouni@vaadin.com> | 2014-08-07 17:51:35 +0000 |
commit | 07ccd642398a5098fdd366458a340681e17b52b2 (patch) | |
tree | 8ddb16dc2b8f5b018423ea929cff2085ec0a825c /client/src | |
parent | 29a3cfc299294f4de688c2e99bb977727d6616a4 (diff) | |
download | vaadin-framework-07ccd642398a5098fdd366458a340681e17b52b2.tar.gz vaadin-framework-07ccd642398a5098fdd366458a340681e17b52b2.zip |
Notification delay is not set to 0 when the notification is clicked (#14368)
Reintroduce the delay timer which triggers the hiding of the
notification. When the notification is clicked, no timer is used, the
notification is hidden immediately.
Change-Id: I93ecc5dcc34c10092b85f4e0daf7ecacfef77f7a
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/com/vaadin/client/ui/VNotification.java | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/client/src/com/vaadin/client/ui/VNotification.java b/client/src/com/vaadin/client/ui/VNotification.java index af7e429340..3cc1afd5ba 100644 --- a/client/src/com/vaadin/client/ui/VNotification.java +++ b/client/src/com/vaadin/client/ui/VNotification.java @@ -81,6 +81,8 @@ public class VNotification extends VOverlay { private boolean infiniteDelay = false; private int hideDelay = 0; + private Timer delay; + private int x = -1; private int y = -1; @@ -260,8 +262,23 @@ public class VNotification extends VOverlay { } } + protected void hideAfterDelay() { + if (delay == null) { + delay = new Timer() { + @Override + public void run() { + VNotification.super.hide(); + } + }; + delay.schedule(hideDelay); + } + } + @Override public void hide() { + if (delay != null) { + delay.cancel(); + } // Run only once if (notifications.contains(this)) { DOM.removeEventPreview(this); @@ -284,23 +301,7 @@ public class VNotification extends VOverlay { } }); } else { - // Use a timer in browsers without CSS animation support - // to show the notification for the duration of the delay - if (BrowserInfo.get().isIE8() || BrowserInfo.get().isIE9()) { - new Timer() { - @Override - public void run() { - VNotification.super.hide(); - } - }.schedule(hideDelay); - } else { - if (hideDelay > 0) { - AnimationUtil.setAnimationDelay(getElement(), hideDelay - + "ms"); - } - VNotification.super.hide(); - - } + VNotification.super.hide(); fireEvent(new HideEvent(this)); notifications.remove(this); } @@ -416,19 +417,19 @@ public class VNotification extends VOverlay { y = DOM.eventGetClientY(event); } else if (Math.abs(DOM.eventGetClientX(event) - x) > mouseMoveThreshold || Math.abs(DOM.eventGetClientY(event) - y) > mouseMoveThreshold) { - hide(); + hideAfterDelay(); } break; case Event.ONMOUSEDOWN: case Event.ONMOUSEWHEEL: case Event.ONSCROLL: - hide(); + hideAfterDelay(); break; case Event.ONKEYDOWN: if (event.getRepeat()) { return true; } - hide(); + hideAfterDelay(); break; default: break; |