0.10.0 • Published 2 years ago

insicht v0.10.0

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

InSicht

Viewport animation using IntersectionObserver.

Make sure to add a polyfill if needed. Check caniuse for more info on support.

Install

npm install insicht

Example Setup

Javascript

import InSicht from 'insicht';

// create an instance with default options
const insicht = new InSicht({
  container: document.documentElement,
  selector: '.insicht',
  visibleClass: 'sichtbar',
  stagger: 100,
  threshold: 0,
  useAnimationDelay: false,
  autoRefresh: false,
  autoReset: false,
  autoRemove: false,
  init: (item, instance) => {},
  done: (item, instance) => {},
});

There are 2 callback functions, init and done. init is run when an item is added and done is run when an item enters the viewport. They both receive 2 arguments, the item and the InSicht instance.

Functions

If you don't have autoRefresh enabled, you can manually refresh the items array, might be useful for ajax websites:

insicht.refresh();

Or you can reset the classes on all items:

insicht.reset();

If you don't need it anymore, you can dispose of it properly:

insicht.destroy();
delete insicht;

CSS

You can overwrite the class that InSicht adds to visible elements, but using the default, it could look something like this:

.selector {
  opacity: 0;
  transition: 0.3s ease-out;
}
.selector.sichtbar {
  opacity: 1;
}

HTML

You can add custom values for staggering individual elements:

<div class="insicht" data-stagger="200"></div>

License

MIT License

0.10.0

2 years ago

0.9.0

4 years ago

0.8.0

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

7 years ago