时间轴制作(响应式)Common.js
/*置顶按钮*/
$(function () {
var e = $("#pawtop"),
t = $(document).scrollTop(),
n,
r,
i = !0;
$(window).scroll(function () {
var t = $(document).scrollTop();
t == 0 ? e.css("background-position") == "0px 0px" ? e.fadeOut("slow") : i && (i = !1, $(".top-1").css("opacity", 1), e.delay(100).animate({
marginTop: "-1000px"
},
"normal",
function () {
e.css({
"margin-top": "-125px",
display: "none"
}),
i = !0
})) : e.fadeIn("slow")
}),
e.hover(function () {
$(".top-1").stop(!0).animate({
opacity: 1
});
},
function () {
$(".top-1").stop(!0).animate({
opacity: 0
});
}),
$(".top-2").click(function () {
function t() {
var t = e.css("background-position");
if (e.css("display") == "none" || i == 0) {
clearInterval(n),
e.css("background-position", "0px 0px");
return
}
switch (t) {
case "0px 0px":
e.css("background-position", "-298px 0px");
break;
case "-298px 0px":
e.css("background-position", "-447px 0px");
break;
case "-447px 0px":
e.css("background-position", "-596px 0px");
break;
case "-596px 0px":
e.css("background-position", "-745px 0px");
break;
case "-745px 0px":
e.css("background-position", "-298px 0px");
}
}
if (!i) return;
n = setInterval(t, 50),
$("html,body").animate({ scrollTop: 0 }, "slow");
});
});
//锚点跳转滑动效果
$(function () {
$('a[href*=#],area[href*=#]').click(function () {
console.log(this.pathname)
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body').animate({
scrollTop: targetOffset
},
1000);
return false;
}
}
});
});
转载

浙公网安备 33010602011771号