Team:NCTU Formosa/source/head

From 2013.igem.org

(Difference between revisions)
Line 9: Line 9:
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="https://2013.igem.org/Team:Team:NCTU_Formosa/js/modernizr.custom?action=raw&ctype=text/javascript"></script>
<script src="https://2013.igem.org/Team:Team:NCTU_Formosa/js/modernizr.custom?action=raw&ctype=text/javascript"></script>
-
<script src="https://2013.igem.org/Team:Team:NCTU_Formosa/js/jquery-scrollspy?action=raw&ctype=text/javascript"></script>
 
<script>
<script>
function adjustStyle(width) {
function adjustStyle(width) {
Line 19: Line 18:
     }
     }
}
}
-
  function() {  
+
$(function () {
-
     $("html").niceScroll();
+
     var top = 0,
 +
        step = 55,
 +
        viewport = $(window).height(),
 +
        body = $.browser.webkit ? $('body') : $('html'),
 +
        wheel = false;
-
  }
+
 
 +
    $('body').mousewheel(function(event, delta) {
 +
 
 +
        wheel = true;
 +
 
 +
        if (delta < 0) {
 +
 
 +
            top = (top+viewport) >= $(document).height() ? top : top+=step;
 +
 
 +
            body.stop().animate({scrollTop: top}, 400, function () {
 +
                wheel = false;
 +
            });
 +
        } else {
 +
 
 +
            top = top <= 0 ? 0 : top-=step;
 +
 
 +
            body.stop().animate({scrollTop: top}, 400, function () {
 +
                wheel = false;
 +
            });
 +
        }
 +
 
 +
        return false;
 +
    });
 +
 
 +
    $(window).on('resize', function (e) {
 +
        viewport = $(this).height();
 +
    });
 +
 
 +
    $(window).on('scroll', function (e) {
 +
        if (!wheel)
 +
            top = $(this).scrollTop();
 +
    });
 +
 
 +
});
$(function() {
$(function() {
     adjustStyle($(this).width());
     adjustStyle($(this).width());

Revision as of 02:36, 30 August 2013