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

How to speed up toaster animation of elFinder? #2487

Closed
mauleous opened this issue Apr 23, 2018 · 3 comments
Closed

How to speed up toaster animation of elFinder? #2487

mauleous opened this issue Apr 23, 2018 · 3 comments
Assignees
Labels

Comments

@mauleous
Copy link

Hi,

I just wanted to share how I speed up toaster animation in elFinder.

For example, there is this toaster notification when creating a new folder. I was looking into speeding up the animation speed of such toaster notification.

create new folder toaster elfinder demo

How I did this is:

  1. Define a new '$.fn.elfinderToastCustom' that runs the original 'elfindertoast' function
$.fn.elfinderToastCustom = function(opts, fm) {
    
    // This is the new default toaster options
    var customDefOpts = {
      mode: 'success',
      msg: '',
      showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
      showDuration: 0, // no animation when showing the toaster
      showEasing: 'swing', //swing and linear are built into jQuery
      onShown: undefined,
      hideMethod: 'fadeOut',
      hideDuration: 200, // quicker animation when hiding the toaster
      hideEasing: 'swing',
      onHidden: undefined,
      timeOut: 1500, // shorter timeout
      extNode: undefined
    };
    
    var customOpts = Object.assign({}, customDefOpts, opts || {}); // combine new default options with provided options
          
    this.elfindertoast(customOpts, fm);    // run the original elfinder toaster
  }  
  1. I defined a new 'toast()' function that runs the new '$.fn.elfinderToastCustom'
function toast(options) {
   return $('<div class="ui-front"/>').appendTo(this.ui.toast).elfinderToastCustom(options || {},this);
};
  1. I overwrote elFinder's toast function -> 'instance.toast = toast;'
elFinderInstance.toast = toast;

If there is a better way to do this, please do let me know.
I hope this helps those who are looking to do the same thing :)

@nao-pon
Copy link
Member

nao-pon commented Apr 23, 2018

@mauleous I'll change it so that we can set default options for toast message animation.

@nao-pon nao-pon self-assigned this Apr 23, 2018
@nao-pon
Copy link
Member

nao-pon commented Apr 23, 2018

@mauleous I added an option uiOptions.toast.defaults

uiOptions : {
    toast : {
        defaults : {
            // to show
            showMethod: 'fadeIn', // fadeIn, slideDown, and show are
built into jQuery
            showDuration: 300,    // milliseconds
            showEasing: 'swing',  // swing and linear are built into
jQuery
            // timeout to hide
            timeOut: 3000,
            // to hide
            hideMethod: 'fadeOut',
            hideDuration: 1500,
            hideEasing: 'swing'
        }
    }
}

Thanks! 👍

@mauleous
Copy link
Author

Cool! That would be even more convenient~ Thanks @nao-pon ! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants