Team:UCLA/Template/Javascript

From 2014.igem.org

(Difference between revisions)
Line 191: Line 191:
</script>
</script>
 +
<!--HP SLIDER-->
 +
<script type="text/javascript">
 +
  $(document).ready(function() {
 +
    $('#hp .slider_left').mouseenter(function(){
 +
          $('#hp .slider_left').animate({ opacity: '0.8'},1);
 +
    });
 +
    $('.slider_right').mouseenter(function(){
 +
          $('#hp .slider_right').animate({ opacity: '0.8'},1);
 +
    });
 +
    $('.slider_left').mouseleave(function(){
 +
          $('#hp .slider_left').animate({ opacity: '0.5'},1);
 +
    });
 +
    $('#hp .slider_right').mouseleave(function(){
 +
          $('#hp .slider_right').animate({ opacity: '0.5'},1);
 +
    });
 +
 +
    var total = $('#hp .slider_imgs > td').length;
 +
    var count = 0;
 +
    $('#hp .slider_left').click(function(){
 +
        if(count > 0){
 +
            $('#hp .slider_imgs').stop(true,true).animate({ left: '+=1150px'}, 250);
 +
            count -= 1;
 +
        } else{
 +
            $('#hp .slider_imgs').stop(true,true).animate({ left: '+=20px'}, 100, function(){$('#hp .slider_imgs').stop(true,true).animate({ left: '-=20px'}, 500)});
 +
        }
 +
    });
 +
    $('#hp .slider_right').click(function(){
 +
        if(count < 2){
 +
            $('#hp .slider_imgs').stop(true,true).animate({ left: '-=1150px'}, 250);
 +
            count += 1;
 +
        } else{
 +
            $('#hp .slider_imgs').stop(true,true).animate({ left: '+=2300px'}, 250);
 +
            count = 0;
 +
        }
 +
    });
 +
  });
 +
</script>

Revision as of 10:43, 17 October 2014