I have a problem with this code ( https://codepen.io/MAJO-SEARCH/pen/gOOyWWb ).
(我对此代码有问题( https://codepen.io/MAJO-SEARCH/pen/gOOyWWb )。)
The problem is that the first time a page is loaded it is cut off a footer and after changing the width of the page everything returns to normal.(问题在于,第一次加载页面时,页面的页脚会被剪切掉,更改页面的宽度后,一切都会恢复正常。)
I don't know how it is caused.(我不知道是怎么引起的。)
Script which is responsible for it is placed at the bottom:(负责该脚本的脚本位于底部:)
var lastPosition = 0;
var html = document.documentElement;
var body = document.body;
html.style.height = body.offsetHeight + 'px';
resizeHandler = function(){
html.style.height = body.offsetHeight + 'px';
}
window.addEventListener('resize',resizeHandler,false);
clickHandler = function(){
wrapper.style.height = smooth.offsetHeight + 'px';
window.scrollTo(0,offsetTop);
smooth.style.transform = 'translate3d(0px, -' + toggle.offsetTop + 'px, 0px)';
lastPosition = window.pageYOffset;
return false;
}
var scroll = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame ||
function(callback) {
window.setTimeout(callback, 1000 / 60)
};
function loop() {
if (lastPosition == window.pageYOffset) {
scroll(loop);
return false;
} else lastPosition = window.pageYOffset;
body.style.transform = 'translate3d(0px, -' + lastPosition + 'px, 0px)';
scroll(loop);
return true;
}
body.addEventListener('scroll',loop,true);
loop();
ask by MAJO translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…