1.1.4 • Published 7 years ago

squintjs v1.1.4

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

SquintJS

A Library for automatically scrolling to an element in the DOM

Description

This library provides the function scrollIntoView which scrolls any element into view. It is pure javascript and so you can use this easily within any framework.

Installation

npm install --save squintjs

or

yarn add squintjs

Demo

https://codepen.io/kylemellander/pen/BwNgNj/

Usage

scrollIntoView

To access you can put this in your javascript:

import { scrollIntoView } from 'squintjs';
Arguments
  • element: (Element) The element you want to bring into view
  • container: (Element) The element that contains the element and contains the scrollbar
  • options: (Object) Options
    • Available options:
      • duration: (integer) time in ms for animation to happen. Defaults to 500.
      • offset: (string || integer) number of pixels to pad the container so that text does not go to the edge of the container. You can also send in a string ending in % (example '10%') which will add a percentage of the height of the container.

Example:

const element = document.getElementById('elementToFind');
const container = document.getElementById('elementScrollingContainer');

scrollIntoView(element, container, { duration: 1000, offset: '10%' });
1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago