原文用 JavaScript 实现了滚动到页面指定位置的功能。
以下这行代码什么意思?
destinationOffsetToScroll 似乎是要滚动的距离,但看不出 documentHeight - destinationOffset < windowHeight 这个条件表达了什么。
const destinationOffsetToScroll = Math.round(documentHeight - destinationOffset < windowHeight ? documentHeight - windowHeight : destinationOffset);
原文在: https://pawelgrzybek.com/page-scroll-in-vanilla-javascript/