Configure Position while Scrolling

let targetPos= targetElement.offsetTop;
let windowScrollPos = document.body.scrollTop;
if (windowScrollPos > targetPos) {
  // Enable targetElement position fixed
} else {
  // Disable targetElement position fixed
}

你可能感兴趣的:(Configure Position while Scrolling)