scroll-anchoring

Preserves the user's scroll position while DOM mutations change the page.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
scroll-anchoring
4900.1.04 years ago4 years agoMinified + gzip package size for scroll-anchoring in KB

Readme

scroll-anchoring
Scroll Anchoring preserves the user's scroll position while DOM mutations change the page.

Installation

$ npm install scroll-anchoring

Usage

import {preserveAnchorNodePosition} from 'scroll-anchoring'

const comments = document.getElementById('comments')
preserveAnchorNodePosition(document, () => {
  comments.insertAdjacentHTML('beforeend', newCommentHtml)
})

Browser support

  • Chrome
  • Firefox
  • Safari
  • Internet Explorer 11
  • Microsoft Edge

Development

npm install
npm test

See Also

License

Distributed under the MIT license. See LICENSE for details.