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

Event onFadeOut fires twice #105

Closed
rowanfreeman opened this issue Aug 14, 2013 · 2 comments
Closed

Event onFadeOut fires twice #105

rowanfreeman opened this issue Aug 14, 2013 · 2 comments
Labels

Comments

@rowanfreeman
Copy link

The event "onFadeOut" fires twice if you dismiss a toast by clicking on it and then move your mouse cursor away.

You can test this by doing the following:

  1. Use this code:
    $(function() {
        toastr.options.onFadeOut = function() { alert("Fired"); };
        toastr.info("Message");
    });
  1. Click on the toastr (so that it dismisses it)
  2. Quickly move your cursor away from the toast
  3. You will get two alerts

Tested with:

  • Chrome 28
  • Firefox 23
  • IE9

Using

  • toastr 1.3.1

I fixed this by adding && response.state != 'hidden' tofadeAway(), but there may be a better solution.

if (options.onFadeOut && response.state != 'hidden') {
    options.onFadeOut();
}
@johnpapa
Copy link
Member

good catch. I'll have to find time to look into this. If anyone has suggestions or a pull request, feel free. The new method is now onHidden as onFadeOut is being deprecated with v2.0.0

@tikicoder
Copy link

the same issue also happens on the onHidden in the function hideToast.
I am using Version 2.0.1
I updated the following lines
if (options.onHidden) {
options.onHidden();
}

to

if (options.onHidden && response.state!='hidden') {
options.onHidden();
}

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

No branches or pull requests

3 participants