Enfoque HTML/CSS
Si usted está buscando una opción que no requiere mucho JavaScript (y y todos los problemas que vienen con él, tales como llamadas de eventos de desplazamiento rápido), es posible obtener el mismo comportamiento agregando un contenedor <div>
y un par de estilos.Me di cuenta de desplazamiento mucho más suave (no hay elementos en declive) cuando utilicé el siguiente enfoque:
JS Fiddle
HTML
<div id="wrapper">
<div id="fixed">
[Fixed Content]
</div><!-- /fixed -->
<div id="scroller">
[Scrolling Content]
</div><!-- /scroller -->
</div><!-- /wrapper -->
CSS
#wrapper { position: relative; }
#fixed { position: fixed; top: 0; right: 0; }
#scroller { height: 100px; overflow: auto; }
JS
//Compensate for the scrollbar (otherwise #fixed will be positioned over it).
$(function() {
//Determine the difference in widths between
//the wrapper and the scroller. This value is
//the width of the scroll bar (if any).
var offset = $('#wrapper').width() - $('#scroller').get(0).clientWidth;
//Set the right offset
$('#fixed').css('right', offset + 'px');
});
Por supuesto, este enfoque podría modificarse para desplazarse por regiones que ganan/pierden contenido durante el tiempo de ejecución (lo que daría como resultado la adición/eliminación de barras de desplazamiento).
Acabo de probar el scrollFollow y parece funcionar de forma brillante. No al instante, como dice Timothy, pero si te alegra que se deslice arriba y abajo de la página, ¡es perfecto! – Paul