diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2009-05-14 12:37:00 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2009-05-14 12:37:00 +0000 |
commit | 3c81fa098bd8ffe8f59af51fec49922dc5e140d4 (patch) | |
tree | ec44a08fcd68ec5f336d0b3c84afed8788ea5ed7 /src/com/vaadin | |
parent | 6d1bc630a09f6fd1bd1a9c2cfa361d8b115fb6a9 (diff) | |
download | vaadin-framework-3c81fa098bd8ffe8f59af51fec49922dc5e140d4.tar.gz vaadin-framework-3c81fa098bd8ffe8f59af51fec49922dc5e140d4.zip |
Avoid flickering of fading animation. null check to avoid multiple animations.
svn changeset:7808/svn branch:6.0
Diffstat (limited to 'src/com/vaadin')
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VNotification.java | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNotification.java b/src/com/vaadin/terminal/gwt/client/ui/VNotification.java index 5567e2d534..23e48437a3 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VNotification.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VNotification.java @@ -133,35 +133,39 @@ public class VNotification extends VToolkitOverlay { public void fade() {
DOM.removeEventPreview(this);
cancelDelay();
- fader = new Timer() {
- private final long start = new Date().getTime();
-
- @Override
- public void run() {
- /*
- * To make animation smooth, don't count that event happens on
- * time. Reduce opacity according to the actual time spent
- * instead of fixed decrement.
- */
- long now = new Date().getTime();
- long timeEplaced = now - start;
- float remainingFraction = 1 - timeEplaced / (float) fadeMsec;
- int opacity = (int) (startOpacity * remainingFraction);
- if (opacity <= 0) {
- cancel();
- hide();
- if (BrowserInfo.get().isOpera()) {
- // tray notification on opera needs to explicitly define
- // size, reset it
- DOM.setStyleAttribute(getElement(), "width", "");
- DOM.setStyleAttribute(getElement(), "height", "");
+ if (fader == null) {
+ fader = new Timer() {
+ private final long start = new Date().getTime();
+
+ @Override
+ public void run() {
+ /*
+ * To make animation smooth, don't count that event happens
+ * on time. Reduce opacity according to the actual time
+ * spent instead of fixed decrement.
+ */
+ long now = new Date().getTime();
+ long timeEplaced = now - start;
+ float remainingFraction = 1 - timeEplaced
+ / (float) fadeMsec;
+ int opacity = (int) (startOpacity * remainingFraction);
+ if (opacity <= 0) {
+ cancel();
+ hide();
+ if (BrowserInfo.get().isOpera()) {
+ // tray notification on opera needs to explicitly
+ // define
+ // size, reset it
+ DOM.setStyleAttribute(getElement(), "width", "");
+ DOM.setStyleAttribute(getElement(), "height", "");
+ }
+ } else {
+ setOpacity(getElement(), opacity);
}
- } else {
- setOpacity(getElement(), opacity);
}
- }
- };
- fader.scheduleRepeating(FADE_ANIMATION_INTERVAL);
+ };
+ fader.scheduleRepeating(FADE_ANIMATION_INTERVAL);
+ }
}
public void setPosition(int position) {
|