2010-08-21 36 views
8

Tengo un div que tiene un ancho del 100% de la ventana, que es un contenedor para el div jScrollPane.jScrollPane cambiar el tamaño

En ventana Cambiar el tamaño del panel de desplazamiento no se mueve, ¿hay alguna forma de hacer jScrollPane cambiar el tamaño con la ventana?

Gracias!

Respuesta

12

Puede usar la llamada a la API reinicializar() para hacer esto. Está cubierto en una de las páginas de ejemplo aquí. http://jscrollpane.kelvinluck.com/dynamic_height.html
http://jscrollpane.kelvinluck.com/dynamic_width.html

$(function() 
{ 
$('.scroll-pane').each(
    function() 
    { 
     $(this).jScrollPane(
      { 
       showArrows: $(this).is('.arrow') 
      } 
     ); 
     var api = $(this).data('jsp'); 
     var throttleTimeout; 
     $(window).bind(
      'resize', 
      function() 
      { 
       if ($.browser.msie) { 
        // IE fires multiple resize events while you are dragging the browser window which 
        // causes it to crash if you try to update the scrollpane on every one. So we need 
        // to throttle it to fire a maximum of once every 50 milliseconds... 
        if (!throttleTimeout) { 
         throttleTimeout = setTimeout(
          function() 
          { 
           api.reinitialise(); 
           throttleTimeout = null; 
          }, 
          50 
         ); 
        } 
       } else { 
        api.reinitialise(); 
       } 
      } 
     ); 
    } 
) 

}); 
7

prefiero algo como esto:

$(window).resize(function(){ 
    $.each($('.scrollcont'), function(){ 
      var api = $(this).data('jsp'); 
      api.reinitialise(); 
    }); 
}); 

Dónde .scrollcont 'es el contenedor de desplazamiento.

Esta secuencia de comandos es útil también si tiene que cambiar el tamaño del tamaño del contenedor de desplazamiento durante la acción.

Cuestiones relacionadas