bakToTop() {
var timer = null;
cancelAnimationFrame(timer);
timer = requestAnimationFrame(
function fn() {
var oTop = document.body.scrollTop || document.documentElement.scrollTop;
if (oTop > 0) {
document.body.scrollTop = document.documentElement.scrollTop = oTop - 50;
timer = requestAnimationFrame(fn);
} else {
cancelAnimationFrame(timer);
}
}
);
},
bakToBot() {
setTimeout(function() {
var timer = null;
//网页正文全文高/网页可见区域高/网页被卷去的高
// console.log(document.documentElement.scrollHeight,document.documentElement.clientHeight, document.documentElement.scrollTop);
cancelAnimationFrame(timer);
timer = requestAnimationFrame(
function fn() {
var oTop = document.body.scrollTop || document.documentElement.scrollTop;
var allTop = document.body.scrollHeight || document.documentElement.scrollHeight;
var canTop = document.documentElement.clientHeight;
// console.log(allTop,canTop, oTop);
if (oTop < (allTop - canTop - 50)) {
document.body.scrollTop = document.documentElement.scrollTop = oTop + 50;
timer = requestAnimationFrame(fn);
} else {
cancelAnimationFrame(timer);
}
}
);
}, 100)
},