Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wideSlider(){
- var status = true; //Esta variable activa la reproducción automática
- var statusload = true;
- var timer; //Este es el intervalo de tiempo para la rotación automática
- var big_positions = new Array(); //Acá guardamos las posiciones de las imágenes grandes
- var amount = $(".bigimages").children("div").children("a").children("img").length; //Cantidad de imágenes
- var preloaded = 0; //Images preloaded counter
- var root = this;
- $(".bigimages").hide();
- $(".bigimages").children("div").children("a").children("img").load(preloaderImages);
- $(".bigimages").children("div").children("a").children("img").each(images);
- function images(){
- if(this.complete && document.all){
- preloaded++;
- if(preloaded >= amount && statusload == true){
- $(".bigimages").fadeIn("slow");
- statusload = false;
- show();
- }
- }
- }
- function preloaderImages(e){
- preloaded++;
- if(preloaded >= amount && statusload == true){
- $(".bigimages").fadeIn("slow"); //Una vez cargadas las imágenes aplico un fade y muestro las imágenes grandes
- statusload = false;
- show(); //Llamo a la función que ejecuta por primera vez el slider
- }
- }
- function show(){
- //Guardo las posiciones de las imágenes grandes
- $(".bigimages").children("div").each(saveBig);
- function saveBig(index,element){
- var width = $(this).width();
- var position = width * index;
- big_positions[index] = position;
- $(this).css("left", position); //Place big images
- }
- //Llamo a la función que produce la reproducción automática por primera vez!
- autoRotation(0);
- function autoRotation(position){
- //Marco la siguiente posición como la actual
- var nextposition = position;
- //Vuelvo a crear el timer
- timer = window.setTimeout(function(e){
- if(nextposition == big_positions.length - 1){ //Si llegue a la última imagen, vuelvo a empezar ;)
- nextposition = 0;
- }else{
- nextposition++;
- }
- //Cuando termina la animación, habilito que pueda existir una siguiente (esto es para evitar los problemas de render de los navegadores y que no aparezcan todas las animaciones juntas cuando maximisamos el navegador antes oculto)
- if(status == true){
- //Animación para las imágenes grandes
- $('.bigimages').animate({right: big_positions[nextposition]},speed * 1000,"swing",function(){ status = true; });
- }
- status = false;
- window.clearTimeout(timer);
- //Genero la recursividad ejecutando nuevamente la función en la que estoy, con esto el loop infinito de animación cíclica
- autoRotation(nextposition);
- }, time * 1000);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement