1

这是我正在开发的网站

http://www.denisstritar.com/DEV/DS3/index.html

当标题固定到该位置时,平滑滚动开始工作。

坚持.js:

function UpdateTableHeaders() {
$(".persist-area").each(function() {

   var el             = $(this),
       offset         = el.offset(),
       scrollTop      = $(window).scrollTop(),
       floatingHeader = $(".floatingHeader",  this)

   if ((scrollTop > offset.top) && (scrollTop < offset.top + el.height())) {
       floatingHeader.css({
        "visibility": "visible"
       });
   } else {
       floatingHeader.css({
        "visibility": "hidden"
       });      
   };
});
}

// DOM Ready      
$(function() {

var clonedHeaderRow;

$(".persist-area").each(function() {
   clonedHeaderRow = $(".persist-header", this);
   clonedHeaderRow
     .before(clonedHeaderRow.clone())
     .css("width", clonedHeaderRow.width())
     .addClass("floatingHeader");

});

$(window)
.scroll(UpdateTableHeaders)
.trigger("scroll");

});

平滑滚动位:

$(document).ready(function() {

  $('ul.mainNavScroll a').smoothScroll();

  $('p.subnav a').click(function(event) {
    event.preventDefault();
    var link = this;
    $.smoothScroll({
      scrollTarget: link.hash
    });
  });

  $('button.scrollsomething').click(function() {
    $.smoothScroll({
      scrollElement: $('div.scrollme'),
      scrollTarget: '#findme'
    });
    return false;
  });
  $('button.scrollhorz').click(function() {
    $.smoothScroll({
      direction: 'left',
      scrollElement: $('div.scrollme'),
      scrollTarget: '.horiz'
    });
    return false;
  });

});

先感谢您!

4

0 回答 0