Team:UCLA/Aal/javascripttemplate

From 2014.igem.org

(Difference between revisions)
Line 12: Line 12:
     });
     });
   });
   });
-
});
 
-
$(document).scroll(function cycleImages() {
 
-
    var images = $('.banner_area img'),
 
-
        now = images.filter(':visible'),
 
-
        next = now.next().length ? now.next() : images.first(),
 
-
        speed = 1000;
 
-
 
-
    now.fadeOut(speed);
 
-
    next.fadeIn(speed);
 
-
}
 
-
$(function () {
 
-
    setInterval(cycleImages, 1400);
 
-
}));
 
-
$(function(){
 
-
 
-
    $('.banner_area img').on('click', scrollToTop);
 
-
});
 
-
 
-
function scrollToTop() {
 
-
    verticalOffset = typeof(verticalOffset) != 'undefined' ? verticalOffset : 0;
 
-
    element = $('body');
 
-
    offset = element.offset();
 
-
    offsetTop = offset.top;
 
-
    $('html, body').animate({scrollTop: offsetTop}, 500, 'linear');
 
-
};
 
-
(function( $ ){
 
-
$.fn.rotator = function(delay, time, child){
 
-
//set curImage val
 
-
var currImg = 0;
 
-
var currIt = true;
 
-
//set array of images
 
-
var ss = $(this).children(child);
 
-
var ssize = ss.size();
 
-
var startTime = new Date().getTime();
 
-
var interval = setInterval(function() {
 
-
if(currIt){
 
-
$(ss[currImg]).css('opacity','1');
 
-
currIt = !currIt;
 
-
}else if (!currIt){
 
-
                $(ss[currImg]).css('opacity','0');
 
-
$(ss[currImg+1]).css('opacity','1');
 
-
currIt = !currIt;
 
-
currImg++;
 
-
}
 
-
//reset
 
-
if(currImg >= ssize){
 
-
currImg = 0;
 
-
$(ss[currImg]).css('opacity','1');
 
-
}
 
-
if(new Date().getTime() - startTime > time){
 
-
clearInterval(interval);
 
-
return;
 
-
}
 
-
}, delay);
 
-
return this;
 
-
};
 
-
})(jQuery);
 
-
$(document).scroll(function() {
 
-
$("#slides").rotator(10, 100, 'img');
 
});
});
</script>
</script>
</html>
</html>

Revision as of 23:43, 3 September 2014