Ver Mensaje Individual
  #3 (permalink)  
Antiguo 11/10/2009, 17:23
sinrazonaparente
 
Fecha de Ingreso: octubre-2009
Mensajes: 2
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: uso de variables para marquesina en jquery

Hola Mayid,

Muchas gracias por la sugerencia, tienes razon con lo de usar clases en la función. Lo cambié y al final me queda así:

Código:
function mostrarFoto(alto,ancho){
			
this.alto = alto;
this.ancho = ancho;
						
 $(".image").css("width", this.ancho);
 $(".image").css("height", this.alto);
 document.getElementById('marquesina').style.width = this.ancho + "px";
 document.getElementById('marquesina').style.height = this.alto + "px";
 document.getElementById('fotos').style.width = this.ancho + 10 + "px";
 document.getElementById('fotos').style.height = this.alto + 10 + "px";
			}
El tem de cambiar el tamaño en la función que hace el movimiento de las marquesinas no es tan fácil como pensé al principio. Conseguí pasarle el tamaño cuando el usario pulsa, pero sólo me sirve para la primera vuelta, cuandolas fotos han el primer loop, vuelve a tomar el valor incial y estamos como al principio.

El movimiento de la marquesina me queda así:

Código:
var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;

          
$(document).ready(function(){
 headline_count = $("div.headline").size();
 $("div.headline:eq("+current_headline+")").css('top','5px');
 headline_interval = setInterval(headline_rotate, 3500);          	  $('#marquesina').hover(function() {
  clearInterval(headline_interval);
  }, function() {
  headline_interval = setInterval(headline_rotate, 3500); headline_rotate();
            });
 	     });
   
function headline_rotate(alto) {
 this.alto = alto;
 if(this.alto == 0){//para que funcione la primera vez
 current_headline = (old_headline + 1) % headline_count;
 $("div.headline:eq(" + old_headline + ")").animate({top: -746},"slow", function(h) {
  $(this).css('top','746px');
  });
  $("div.headline:eq(" + current_headline + ")").show().animate({top: 5},"slow");  
  old_headline = current_headline;
  }else{
 current_headline = (old_headline + 1) % headline_count;
 $("div.headline:eq(" + old_headline + ")").animate({top: -this.alto},"slow", function(h) {
  $(this).css('top',this.alto + 'px');
  });
  $("div.headline:eq(" + current_headline + ")").show().animate({top: 5},"slow");  
  old_headline = current_headline;
}
}
Me temo que tengo que darle un par de vueltas más.

Muchas gracias de todas formas.