title: Smooth jScrollPane scrollbar length adjustment with dynamic content
body: <p>Some of my webpages contain several text elements that expand and collapse with a jQuery "accordion" effect:</p>
  
  <pre><code>function show_panel(num) {
      jQuery('div.panel').hide();
      jQuery('#a' + num).slideToggle("slow");
  }
  
  function hide_panel(num) {
      jQuery('div.panel').show();
      jQuery('#a' + num).slideToggle("slow");
  }
  </code></pre>
  
  <p>This causes the window size to change so jScrollPane has to be reinitialized, which will also change the length of the scrollbar. To achieve a smooth length adjustment of the scrollbar, I set the "autoReinitialise" option to "true" and the "autoReinitialiseDelay" to "40" ms:</p>
  
  <pre><code>$(document).ready(function () {
  var win = $(window);
  // Full body scroll
  var isResizing = false;
  win.bind(
      'resize',
  
  function () {
      if (!isResizing) {
          isResizing = true;
          var container = $('#content');
          // Temporarily make the container tiny so it doesn't influence the
          // calculation of the size of the document
          container.css({
              'width': 1,
                  'height': 1
          });
          // Now make it the size of the window...
          container.css({
              'width': win.width(),
                  'height': win.height()
          });
          isResizing = false;
          container.jScrollPane({
              showArrows: false,
              autoReinitialise: true,
              autoReinitialiseDelay: 40
          });
      }
  }).trigger('resize');
  
  // Workaround for known Opera issue which breaks demo (see
  // http://jscrollpane.kelvinluck.com/known_issues.html#opera-scrollbar )
  $('body').css('overflow', 'hidden');
  
  // IE calculates the width incorrectly first time round (it
  // doesn't count the space used by the native scrollbar) so
  // we re-trigger if necessary.
  if ($('#content').width() != win.width()) {
      win.trigger('resize');
  }
  
  });
  </code></pre>
  
  <p>The effect is ok, but on the cost of a very high CPU usage which makes my fan go wild. </p>
  
  <p>This is a jsfiddle which shows the settings and the effect: <a href="http://jsfiddle.net/VVxVz/" rel="nofollow">http://jsfiddle.net/VVxVz/</a></p>
  
  <p>Here's an example page (in fact it's an iframe within the webpage shown): <a href="http://www.sicily-cottage.net/zagaraenausfluege.htm" rel="nofollow">http://www.sicily-cottage.net/zagaraenausfluege.htm</a></p>
  
  <p>Is there a possibility to achieve the same "smooth" transition of the scrollbar length without using the "autoReinitialise" option, maybe with an additional script, some modification of the jscrollpane.js, or simply a css animation of the scrollbar and then calling the reinitialise manually?</p>
  
  <p>I'm absolutely useless at javascript so any help would be greatly appreciated.</p>