title: How to chain .call() functions - adding transitions to Nivo Lightbox
body: <p>I'm trying to impliment CSS animation transitions for items displayed in a Nivo Lightbox. 
  I've got the new function inserted and running, but the 2 following functions run before it is complete.</p>
  
  <pre><code>$('.nivo-lightbox-prev').off('click').on('click', function(e){
      e.preventDefault();                
      var index = galleryItems.index(currentLink);
      currentLink = galleryItems.eq(index - 1);
      if(!$(currentLink).length) currentLink = galleryItems.last();
      $this.options.beforePrev.call(this, [ currentLink ]);  # &lt;---- new function I added
      $this.processContent(content, currentLink);            # &lt;---- existing function 1
      $this.options.onPrev.call(this, [ currentLink ]);      # &lt;---- existing function 2
  });
  </code></pre>
  
  <p>The only way I know would be to put them in a callback, but .call() doesn't accept a callback. </p>
  
  <p>I tried this:</p>
  
  <pre><code>function beforePrev(callback){
      $this.options.beforePrev.call(this, [ currentLink ]);
      callback();
  }
  function onPrev(){
      $this.processContent(content, currentLink);
      $this.options.onPrev.call(this, [ currentLink ]);
  }
  beforePrev(onPrev);
  </code></pre>
  
  <p>but it behaved the same.</p>
  
  <p>In case it's relevant the code for beforePrev is: </p>
  
  <pre><code>beforePrev: function() {
      el = $('.nivo-lightbox-content');
      el.addClass('animated fadeOutLeft');
      el.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function (e) {
          el.removeClass('fadeOutLeft');
      });
  },
  </code></pre>
  
  <p>Can anyone point me in the right direction?</p>
  
  <hr>
  
  <p>Update / edit for extra clarity:
  This is the full original Nivo code: <a href="https://github.com/gilbitron/Nivo-Lightbox/blob/master/nivo-lightbox.js" rel="nofollow">link</a></p>
  
  <p>From my reading of it, <code>$this</code> is just a standard variable referring to the init function, not a DOM object. I think this is one of the reasons this seems hard to do.</p>