ryanto / ember-flash-message

Flash message for Ember.JS templates.
49 stars 23 forks source link

Add ability to auto dismiss flash messages using a timer #16

Open Emerson opened 10 years ago

Emerson commented 10 years ago

I'm at a point in my project where I'd like to have flash messages automatically disappear after a certain amount of time. Ideally, they would be animated out - something that users would want to configure on an app by app basis.

I've been hacking away on this locally, but have not been able to find a clean solution yet.

In terms of API, I was thinking something along the lines of:

this.flashMessage('I will disappear in 0.5 seconds', 'success', 500);

Once the 500 milliseconds is up, some kind of callback would be triggered on the view, which the user could just extend in their own application to create the desired animation.

I'm hitting a couple problems trying to get this to work:

Any thoughts on this would be much appreciated. I may just hack it into my project and come back to this later.

ryanto commented 10 years ago

Cool - I'll take a look at getting the test to pass and we can go from there. I like the idea a lot.

josh-padnick commented 10 years ago

The update from @Emerson to add timing works very nicely, and I'm using it in my project now. I've tested it successfully with Chrome, Firefox, and Safari. Haven't been able to test in IE9+ yet. The one issue I noticed -- and maybe this is an unrelated bug -- is that the fadeOut() animation applies correctly the first time the alert closes, but not on subsequent times.

Emerson commented 10 years ago

Ideally that fadeOut functionality would be user defined, just not sure the best way to make that happen.

Also - just pushed a small fix to my PR (unrelated to your problem)

cristinawithout commented 9 years ago

I'd also like that feature. Though I'd prefer it on a message by message basis rather than app by app.

An example use-case is in a single app, you might have messages that are important enough that you want to make sure the user sees them and they don't just fade away ("changes failed to save. please do XYZ and try again.") and other messages that provide the user comforting feedback so they know things are happening but aren't critical for the user to see and take action upon ("changes saved successfully").