var timer;
$(function(){
//捲軸滾動觸發
$(window).scroll(function(){
clearInterval(timer);
var topScroll=getScroll();
var topDiv="100px";
var top=topScroll+parseInt(topDiv);
timer=setInterval(function(){
//動畫移動
$(".test").animate({"top":top},500);
},500)
})
function getScroll(){
var bodyTop = 0;
if (typeof window.pageYOffset != "undefined") {
bodyTop = window.pageYOffset;
} else if (typeof document.compatMode != "undefined" && document.compatMode != "BackCompat") {
bodyTop = document.documentElement.scrollTop;
}
else if (typeof document.body != "undefined") {
bodyTop = document.body.scrollTop;
return bodyTop
var timer;
$(function(){
//捲軸滾動觸發
$(window).scroll(function(){
clearInterval(timer);
var topScroll=getScroll();
var topDiv="100px";
var top=topScroll+parseInt(topDiv);
timer=setInterval(function(){
//動畫移動
$(".test").animate({"top":top},500);
},500)
})
})
function getScroll(){
var bodyTop = 0;
if (typeof window.pageYOffset != "undefined") {
bodyTop = window.pageYOffset;
} else if (typeof document.compatMode != "undefined" && document.compatMode != "BackCompat") {
bodyTop = document.documentElement.scrollTop;
}
else if (typeof document.body != "undefined") {
bodyTop = document.body.scrollTop;
}
return bodyTop
}