auto scroll bottom in js
autoScrollToBottom() {
let box = document.querySelector(`[data-dom="chatroom-content"]`);
let height = box.scrollHeight;
box.scrollTo(0, height);
},
demo
refs
https://developer.mozilla.org/en-US/docs/Web/API/Window/scroll
https://mdn.github.io/dom-examples/scrolltooptions/
https://github.com/mdn/dom-examples/tree/master/scrolltooptions
window.scroll(x-coord, y-coord)
window.scroll(options)
https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions
https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo
window.scrollTo(x-coord, y-coord)
window.scrollTo(options)
https://www.cnblogs.com/xgqfrms/p/9416358.html
https://www.cnblogs.com/xgqfrms/p/9707267.html
window.requestAnimationFrame
https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame
// setTimeout(() => {
// this.goToTop.current.style.display = "none";
// }, 1000);
let timestamp = 1000;
function step() {
timestamp --;
if (timestamp > 0) {
window.requestAnimationFrame(step);
} else {
this.goToTop.current.style.display = "none";
}
}
window.requestAnimationFrame(step);
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!