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

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

Open
Emerson opened this issue Jul 14, 2014 · 4 comments
Open

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

Emerson opened this issue Jul 14, 2014 · 4 comments

Comments

@Emerson
Copy link
Collaborator

Emerson commented Jul 14, 2014

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:

  • I think the fact that we are creating anonymous views makes it impossible to have some kind of extendable callback.
  • Testing this stuff is brutal due to way qunit handles the run loop and async tests in general.

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

@ryanto
Copy link
Owner

ryanto commented Jul 14, 2014

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
Copy link

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
Copy link
Collaborator Author

Emerson commented Aug 18, 2014

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
Copy link

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").

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

4 participants