JSPM

view-in

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q19106F
  • License ISC

A dependency free utility to set and remove animation classes on elements as they become visible in the viewport, using the Intersection Observer API

Package Exports

  • view-in

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (view-in) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

A work in progress do not use

ViewIn.js

A simple utility to apply and remove classes to DOM elements as they enter the view port, using the Intersection Observer API.

Usage

viewIn('.my-selector', options);

Options

classOnEnter - css class name to add when an element enters the viewport

classOnExit - css class name to add when an element leaves the view port

exitThreshold - what % of the element is remaining in the viewport before classOnExit is applied

enterThreshold - what % of the element is visible in the viewport before classOnEnter is applied.

To Do

  • Add IS feature detection
  • Error cases
  • once: boolean - only trigger the observerable once
  • Tidy up