scroll-into-center

0.1.0 • Public • Published

scroll-into-center

This script provides a polyfill to support unstandardised Element.scrollIntoCenter(), similar to the standard scrollIntoView. The functionality has been suggested before as a possible addition to scrollIntoView, which always aligns the element with the top of the view.

Usage

Simply include the script, and every DOM element will have the method scrollIntoCenter({options}).

option fields:

  • vertical: scalar between 0 and 1. Default = 0.5. The value 0 aligns the top of the element with the top of the view, 1 aligns the bottom with the bottom, and 0.5 (default) puts the center in the center.

  • horizontal: scalar between 0 and 1. Default = 0.5. Functions like vertical.

Package Sidebar

Install

npm i scroll-into-center

Weekly Downloads

2

Version

0.1.0

License

CC0-1.0

Last publish

Collaborators

  • treora