Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications may remain opened or dismiss immediately without showing #17

Closed
nzamosenchuk opened this issue Jul 2, 2015 · 6 comments
Closed

Comments

@nzamosenchuk
Copy link

Notifications may remain opened or dismiss immediately without showing. I'm still investigating those two problems. But, so far can provide such details:

  • Opacity of Notifications that remain opened/visible is constantly increasing.

Usecase:

  • Preview button sends request to the server. If server responds with an error, sticky notification is shown. Button is disable while request is performed.
  • Server always responds with error.
  • When clicking clicking lots of times, notification stops fading-in and is simply displayed. Close button doesn't do anything. Opacity starts increasing without limit.

It's very hard to reproduce when starting a 'grunt serve', but in production environment it is easily reproducible.

@nzamosenchuk
Copy link
Author

What might theoretically be, is that:

 notifyInterval = $interval(func, FADE_INTERVAL);

(line:285) is invoked multiple times overriding the value of notifyInterval variable. And then only the one is really canceled (line:279 & 352).

@nzamosenchuk
Copy link
Author

The workaround might be like this (piece of doFade func):

                var doFade = function(mode, opacity, duration, callback) {

                    var gap = FADE_INTERVAL / duration;

                    notifyScope.ngNotify.notifyStyle = {
                        display: 'block',
                        opacity: opacity
                    };
                    var func = function() {
                        opacity += mode * gap;
                        notifyScope.ngNotify.notifyStyle.opacity = opacity;

                        if (opacity <= OPACITY_MIN || OPACITY_MAX <= opacity) {
                            callback();
                        }
                    };
                    var iterations = 0;
                    if (mode>0)
                    {
                      iterations = Math.ceil((OPACITY_MAX - opacity) / gap);
                    } else{
                      iterations = Math.ceil((opacity - OPACITY_MIN) / gap)
                    }
                    notifyInterval = $interval(func, FADE_INTERVAL, iterations);

Idea is to calc the number of iterations required to achieve min/max opacity. Math.ceil will ensure it will be achieved, always rounding to higher integer. And actual func() won't cancel any promises, but will only notify callback. It will be better to count iterations in func and call calback on the last invocation, but I tried to make changes as small as possible. Rest is for You to decide.

It doesn't solve the problem of multiple invocations of $interval, but still solves the bug with constantly hidden or constantly visible notifications. I've tested on my server and it works now.

@matowens
Copy link
Owner

Hey there @nzamosenchuk and @droritos, sorry for the delay, it's been crazy busy lately.

I was also able to replicate the issue you're both seeing by clicking the "x" on a sticky notification multiple times before it disappeared. I've added an update that seems to have resolved the issue, a check to make sure we don't overwrite any currently running intervals without canceling them out.

Give it a look and let me know if you're still running into any issues. Thanks for your help, it's much appreciated!!

@matowens
Copy link
Owner

matowens commented Aug 7, 2015

Gonna go ahead and close this guy. Let me know if you continue to see anything. Thanks!

@matowens matowens closed this as completed Aug 7, 2015
@beuted
Copy link

beuted commented Aug 19, 2015

I had issue where ngNotify.dismiss() was preventing any other notification, upgraded from 0.6.2 to 0.6.3 and it works just fine, thanks 👍

@beuted
Copy link

beuted commented Jul 25, 2016

Update: The opacity bug is fixed but some sticky notification do not get dismissed when .dismiss() is called.
I could not figure a way to make it work (neither with 0.6.3 nor with 0.8.0) so I just stopped using the sticky: true option :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants