Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/02/2011, 15:35
a123456
 
Fecha de Ingreso: octubre-2010
Mensajes: 4
Antigüedad: 13 años, 7 meses
Puntos: 0
Pregunta Ventana Deslizante

Necesito ayuda para crear una ventana deslizante dentro de mi Web. Ya tengo un código js que lo utilizo para que se deslice mi ventana, pero lo que necesito es que cuando llegue a un punto en "y" EJ: 100 px se detenga, aunque el scroll de la Web puede seguir bajando.

Código Javascript:
Ver original
  1. var capa =
  2. {
  3. topMargin : 1 ,
  4. ceiling : 55 ,
  5. desplazaTime : 1200 ,
  6. capaDiv : document.all ? document.all.capa :
  7. (document.layers ? document.capa : document.getElementById('capa'))
  8. }
  9.  
  10. window.setInterval("capa.coordenadas( )", 35)
  11.  
  12. capa.coordenadas = function( )
  13. {
  14. if(document.all)
  15. {
  16. this.actualY = this.capaDiv.style.pixelTop;
  17. this.scrollTop = document.body.scrollTop;
  18. }
  19. else if(document.layers)
  20. {
  21. this.actualY = this.capaDiv.top;
  22. this.scrollTop = window.pageYOffset;
  23. }
  24. else if(document.getElementById)
  25. {
  26. this.actualY = parseInt(this.capaDiv.style.top);
  27. this.scrollTop = window.pageYOffset;
  28. }
  29.  
  30. var nuevoScrollTop = Math.max( this.scrollTop + this.topMargin, this.ceiling );
  31.  
  32. if ( this.actualY != nuevoScrollTop )
  33. {
  34. if ( nuevoScrollTop != this.targetY )
  35. {
  36. this.targetY = nuevoScrollTop;
  37. this.desplazaInit( );
  38. }
  39. this.desplaza( );
  40. }
  41. }
  42. capa.desplazaInit = function( )
  43. {
  44. var ahora = new Date( )
  45. this.A = this.targetY - this.actualY ;
  46. this.B = Math.PI / ( 2 * this.desplazaTime );
  47. this.C = ahora.getTime( );
  48. this.D = this.actualY;
  49. }
  50.  
  51. capa.desplaza = function( )
  52. {
  53. var ahora = new Date( );
  54. var nuevaY = this.A * Math.sin( this.B * ( ahora.getTime( ) - this.C ) ) + this.D;
  55. nuevaY = Math.round( nuevaY );
  56.  
  57. if ( ( this.A > 0 && nuevaY > this.actualY ) || ( this.A < 0 && nuevaY < this.actualY ) )
  58. {
  59. if (document.all)
  60. this.capaDiv.style.pixelTop = nuevaY;
  61. else if(document.layers)
  62. this.capaDiv.top = nuevaY;
  63. else if(document.getElementById)
  64. this.capaDiv.style.top = nuevaY;
  65. }
  66. }

No se en que punto de este código colocar un "IF"
EJ.
if(y == "100px"){
capa YA NO TE MUEVAS
}else{
capa PUEDES MOVERTE
}

PD: Entonces cuando llegue a las 100px ya no te muevas. Ahora, si movemos el scroll de la Web para arriba, la ventana debe seguir deslizándose ahora para arriba. Hasta llegar a un punto fijo, a su poscicion inicial, marcada con la variable: topMargin : 1
PD2: Mi ventana la llamo por el ID del DIV "capa".

Espero que puedan ayudarme!!