Materialize: Raising a toast without any fadeout timer

Created on 17 Dec 2015  Â·  7Comments  Â·  Source: Dogfalo/materialize

Hi guys,

I'm not sure if my request actually aligns with material design, but I'm having a need to make some toasts stay on the screen until the user dismisses it, without any timer to fade it out.

I figured I could modify the js and make a condition around the counterInterval definition to only apply it if the displayLength is not 0 (then passing 0 as displayLength makes the toast stay on until dismissed by user). I'd however, rather not make changes to the js files to prevent making future upgrades more complicated.

Is this even the right place for making feature requests?

Thanks,
Joseph.

Most helpful comment

M.toast({html: 'hi', displayLength: Infinity}) should work

All 7 comments

I think if you leave the duration blank it will stay until dismissed
On Dec 17, 2015 3:21 AM, "yzargari" [email protected] wrote:

Hi guys,

I'm not sure if my request actually aligns with material design, but I'm
having a need to make some toasts stay on the screen until the user
dismisses it, without any timer to fade it out

I figured I could modify the js and make a condition around the
counterInterval definition to only apply it if the displayLength is not 0
(then passing 0 as displayLength makes the toast stay on until dismissed by
user) I'd however, rather not make changes to the js files to prevent
making future upgrades more complicated

Is this even the right place for making feature requests?

Thanks,
Joseph

—
Reply to this email directly or view it on GitHub
https://github.com/Dogfalo/materialize/issues/2495.

you just need to show your toast like this
Materialize.toast('I am a toast!') // unlimit toast

Hi guys,
I'm only getting around to checking your suggestions now (I was quite comfortable with the workaround I did for myself back in December) and I see how leaving the duration blank makes a toast that stays on.

My problem is this: I need to specify a custom CSS class, which is the third parameter when calling the toast function - so how do I leave the duration blank? I tried the following ways and got a toast that displayed and immediately get removed:
Materialize.toast('I am a toast!', 0, 'custom_css_class');
Materialize.toast('I am a toast!', '', 'custom_css_class');
Materialize.toast('I am a toast!', null, 'custom_css_class');

With some trial and error, I found I could provide any string as duration and that would result in a non-expiring toast - Materialize.toast('I am a toast!', "stay on", 'custom_css_class');

BUT...... if you call the toast function without duration, it would still set the interval and run every 20ms. While it may not count as a catastrophe, it makes absolutely no sense overloading the browser with unnecessary work.

I still believe that wrapping the setInterval with if (parseInt(displayLength)) is the better solution.

Any update on this?

It would be great to have a default option to make toasts live until the user dismiss them

M.toast({html: 'hi', displayLength: Infinity}) should work

Was this page helpful?
0 / 5 - 0 ratings

Related issues

heshamelmasry77 picture heshamelmasry77  Â·  3Comments

artur99 picture artur99  Â·  3Comments

SoproniOli713 picture SoproniOli713  Â·  3Comments

djensen47 picture djensen47  Â·  3Comments

lpgeiger picture lpgeiger  Â·  3Comments