1.1.1 • Published 2 years ago

appear-on-scroll v1.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

appear-on-scroll

Show elements as they enter the browser viewport on scroll.

Getting Started

To get up and running quickly, install the package.

npm install appear-on-scroll --save

Then, initialize it.

import {AppearOnScroll} from 'appear-on-scroll';

const appearOnScroll = new AppearOnScroll(`.appear-on-scroll`, {
	duration: 850,
	once: true,
	slideDistance: `10px`,
});

The first parameter of the AppearOnScroll function is selector and it takes any CSS selector as an argument. The second parameter is options and it takes an object as an argument. In the example above I'm overriding some of the default option values, but you may omit any of them to simply use the defaults.

Options

KeyValue TypeDefault ValueDescription
delayNumber0Delay (in milliseconds) before the element will be shown after entering the browser viewport.
durationNumber600Duration (in milliseconds) of the animation to show the element.
easingStringcubic-bezier(0.5, 0, 0, 1)Duration (in milliseconds) of the animation to show the element.
onceBooleanfalseWhether or not the element will be hidden and shown again upon leaving and reentering the browser viewport.
slideBooleantrueWhether or not the element will "slide" into place as it's being shown. This is dependent on scroll direction to give it a more natural feel.
slideDistanceString25pxHow far the element will "slide" into place as it's being shown. This property is dependent on the slide property being set to true.

Authors

Dave Maynard - GitHub

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago