Ver Mensaje Individual
  #5 (permalink)  
Antiguo 28/01/2014, 06:44
koruitch
 
Fecha de Ingreso: marzo-2010
Mensajes: 41
Antigüedad: 14 años, 2 meses
Puntos: 0
Respuesta: Scroll div, en div contenedor con alto variable

Pude conseguir otro codigo para esto. Haber que me falta porque no logro que me funcione.

Código Javascript:
Ver original
  1. (function(a){a.fn.extend({scrollFixed:function(b){var d=a.extend({topSpacing:0,parent:null},b);var f=a(window),e=a(document);return this.each(function(){var h=a(this),o=d.parent?d.parent:h.parent(),k=a("<div></div>"),j=false,p=h.height(),n=h.offset().top,l=o.height(),m=o.offset().top;k.css("height",p);k.insertAfter(h);h.css("position","absolute");
  2.  
  3. function g(){if(e.scrollTop()+d.topSpacing>n&&l+m-e.scrollTop()-p>0){
  4.     if(!j){j=true;h.css({position:"fixed",top:d.topSpacing})}
  5.     }else{
  6.     if(j){j=false;if(l+m-e.scrollTop()-p>0){h.css({position:"absolute",top:""})
  7.     }else{
  8.     h.css({position:"absolute",top:l+m-p+d.topSpacing})}}}}f.on("scroll",g);setInterval
  9.  
  10. (function(){var q=false;if(h.height()!=p){p=h.height();
  11.             k.css("height",p);q=true}if(k.offset().top!=n){n=k.offset().top;
  12.             q=true}if(o.height()!=l){l=o.height();q=true}
  13.             if(o.offset().top!=n){m=o.offset().top;q=true}
  14.             if(q){g()}},1000)})}})})(jQuery);
  15.             $(".fixme").scrollFixed({topSpacing:-15,parent:$($(".fixme").data("parent"))});

Y luego en el div uso:

Código HTML:
<div class="fixme" data-parent="#bg_post"> 
No logro que me funcione el style ¿que se lo que me falta? ¿o que ago mal?