sotsera / sotsera.blazor.toaster

A Toastr.js port to Blazor in pure .Net.
https://blazor-toaster.sotsera.com/
MIT License
130 stars 29 forks source link

Add support for timeout and extendedTimeout #11

Closed ebekker closed 6 years ago

ebekker commented 6 years ago

Great library! Looks like you actually re-implemented the same behavior based on the original toastr.js instead of just wrapping it, correct?

I was wondering if it's possible to extend it to include two of the original properties, timeout and extendedTimeout as described here.

I'm thinking of scenarios where I want to display a critical message (error or warning) and I don't want to have it fade away automatically and instead require the user to interact with and acknowledge the toast (timeout = 0; extendedTimeout = 0').

ghidello commented 6 years ago

Ciao Eugene and thanks for your kind words! Yes, I tried to reimplement the functionalites in c# avoiding javascript completely.

I just pushed to the dev branch and to the online sample a new version that allows the auto fade out to be disabled setting the VisibleStateDuration (which correspond to the original toastr.js timeout option) property to zero for a toast. If you can test it out and see if it works as you did expect I'll go ahead and push it to nuget.

I didn't implement the extendedTimeout so, in my version, when the mouse enters a toast it doesn't start to fade out until it is clicked or when the mouse leaves. Does it make sense or do you think that extendedTimeout would be useful?

ebekker commented 6 years ago

Thanks for the quick turn around. I will give this a try shortly.

Regarding extendedTimeout -- the behavior I was going for was to have the user "click" the message -- as I stated before, this is for displaying a critical error, so I want to be sure the user sees it, has time to process it, and intentionally dismisses it.

Ideally, replicating the disabled extendedTimeout would be great for this scenario, but even the addition of timeout behavior is great!

ghidello commented 6 years ago

Ciao Eugene, have you got a chance to test the dev version or the published sample?

ghidello commented 6 years ago

I just pushed a new version (0.5.3) where I reverted the change to the VisibleStateDuration and added a new configuration option named RequireInteraction which looks more explicit to me. what do you think about it?

ghidello commented 6 years ago

Hey, any update on this?

ebekker commented 6 years ago

@ghidello -- so sorry for the long delay, as often happens from time to time, my little project where I was using your great component got backburnered and didn't have a chance to try out your changes.

But I just dropped in your lib into a new project, wired up the options as described here and it works great, thank you!

It's especially cool that I can intermix the behavior of different messages (i.e. some auto-fade, while others require user interaction). It's the best of all worlds!

ghidello commented 6 years ago

I know what you mean about side projects being backburnered :disappointed: I'm very glad this issue worked out correctly and thanks for for the very nice comment and helping making the library better. If you have any other suggestion I'm all ears.

ebekker commented 6 years ago

Thanks -- here's my latest creation using your lib