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

Support Toastr's newestOnTop config #15

Closed
bvaughn opened this issue Aug 11, 2014 · 3 comments
Closed

Support Toastr's newestOnTop config #15

bvaughn opened this issue Aug 11, 2014 · 3 comments

Comments

@bvaughn
Copy link

bvaughn commented Aug 11, 2014

I noticed after switching from pure JS Toastr implementation over to Angular-Toastr that my new toasts were being added to the bottom of the list. This has an unfortunate side effect of making the fade-out look a little jumpy. I thought at first that changing this behavior would just be a matter of changing toastrConfig like...

toastrConfig.newestOnTop = true;

But this didn't seem to have any impact. Next I dug into the source code. Here's the relevant bit of the Toastr source:

function addToast(toast) {
  // Hidden for brevity
if (mergedConfig['newest-on-top'] === true) {
  scope.toasters.unshift(toast);
  // Hidden for brevity
} else {
  scope.toasters.push(toast);
  // Hidden for brevity
}

I'm not sure this is quite so straight forward to implement in your version of Toastr because of how you're using $animate.enter but I think a similar thing could be accomplished by making the following two changes:

Assign a placeholder first child in setContainer
container = angular.element('<div><i></i></div>'); // <i> could be any other inline element
Check toastrConfig and parent the new toast appropriately in _notify
_setContainer(options).then(function() {
  var after = toastrConfig.newestOnTop ? container.find('i') : null; // You could change the default

  $animate.enter(newToast.el, container, after, function() {

Any chance you could make this change?

PS. For what it's worth, I tested this change locally and it seems to work. I'll submit a PR shortly.

bvaughn pushed a commit to bvaughn/angular-toastr that referenced this issue Aug 11, 2014
@bvaughn
Copy link
Author

bvaughn commented Aug 11, 2014

New PR submitted: #16

@Foxandxss
Copy link
Owner

That is done now mate.

@bvaughn
Copy link
Author

bvaughn commented Oct 16, 2014

Thanks :)

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