您好,欢迎来到源码搜藏!分享精神,快乐你我!提示:担心找不到本站?在百度搜索“源码搜藏”,网址永远不丢失!
  • 首 页
  • 在线工具
  • 当前位置:首页 > 网页特效 > jQuery特效 >

    jquery+html5视差滚动标题固定显示代码

    时间:2014-10-10 08:17 来源:互联网 作者:源码搜藏 浏览:收藏 挑错 推荐 打印

    效果预览 进入下载地址列表
    html5视差滚动标题固定显示代码html5视差滚动标题固定显示代码是一款基于jquery+html5实现的页面视差滚动标题固定显示效果代码。jqueryhtml5视差滚动标题固定

      <script> 
        $(document).ready(function(){
          // vh fix for iOS7 (Not that it works well on that anyway)
          viewportUnitsBuggyfill.init();
     
          $(window).resize(function(){
            viewportUnitsBuggyfill.refresh();
          });
     
          // Start Midnight!
          $('nav.fixed').midnight();
     
          // Start wow.js
          new WOW().init();
     
          // The island disappears when the logo moves on top of it
          var $island = $('#space-island');
          var islandTop = $island.offset().top;
          var windowHeight = $(window).height();
     
          $(window).resize(function(){
            islandTop = $island.offset().top;
            windowHeight = $(window).height();
          });
     
          $(document).scroll(function(){
            var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
            var minScrollTop = islandTop - windowHeight * 0.4;
            var maxScrollTop = islandTop;
     
            // Opacity goes from 1.0 at the bottom 2/3 of the screen to 0.4 at the top
            if( scrollTop <= islandTop*2 ) {
              var targetOpacity = 1.0;
              var minOpacity = 0.4;
     
              if( scrollTop > minScrollTop && scrollTop < maxScrollTop ) {
                targetOpacity = ((maxScrollTop - scrollTop) / (maxScrollTop - minScrollTop)) * (1.0 - minOpacity) + minOpacity;
              }
              else if( scrollTop > maxScrollTop ) {
                targetOpacity = minOpacity;
              }
              else if( scrollTop < minScrollTop ) {
                targetOpacity = 1.0;
              }
     
              $island.css('opacity', targetOpacity);
            }
     
          });
     
          $('.scroll-prompt').click(function(event){
            event.preventDefault();
            $('html, body').animate({
              scrollTop: $("section.step-one").offset().top - $('nav').height() * 0.5
            }, 1000, 'swing');
          });
     
          $(window).trigger('resize');
     
        });
      </script>
    jquery+html5视差滚动标题固定显示代码由源码搜藏网整理,转载请注明出处http://www.codesocang.com/texiao/jQuerytexiao/10354.html 源码搜藏承诺:本站所有资源无病毒,无弹窗,无干扰链接!