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

Correlate a Toast with the one which has Just Hidden #675

Open
DavidRogersDev opened this issue Nov 13, 2021 · 1 comment
Open

Correlate a Toast with the one which has Just Hidden #675

DavidRogersDev opened this issue Nov 13, 2021 · 1 comment

Comments

@DavidRogersDev
Copy link

It would be good if the onHidden callback passed a parameter enabling the executing code to identify which Toast was being hidden.

Currently, there's no way to correlate a toast that is hiding/hidden.

In the scenario I am facing, I am pushing each message into a MessageBoard at the top of the page as the onHidden handler fires.
But they may hide in a different order that that in which they are launched.
For example, a user may hover over one Toast, meaning that a Toast which came after it hides before it.

This messes up the order in which messages are added to the message board.

As a work around, I'm now adding them to the board as the Toast is launched. But it would be more elegant to add it when the Toast disappears.

Cheers

@rbdeenk
Copy link

rbdeenk commented Nov 23, 2021

Have you tried looking at the code on the demo page. There is a black/gray bar in the bottomif you click on it you'll see what they call glimpse. If you fire a toast you will see it appear in the glimpse, you'll also see it there when it dissappears. This javascript file has some features which may help you for example

    toastr.subscribe(receiveToasts);

    function receiveToasts(args) {
        var data = args;
        !rendered ? preexistingToasts.push(data) : write(data);
    }

By subscribing a function to the toast it'll trigger on completion. I have my doubts if this works onclick though.

The code in the function pushes the toast to the preexistingToasts when its not being rendered anymore. I hope this hint can help you achieve your goal (this isn't a complete tutorial i suggest reading and understanding the code in the javascript file).

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

2 participants