JSPM

interserver

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q20567F
  • License MIT

IntersectionObserver simplified

Package Exports

  • interserver

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 (interserver) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Interserver

IntersectionObserver simplified

Interserver is an easy way to check if a dom element is intersecting the viewport.

Features

  • Tiny (~1kb minified)
  • TypeScript ready
  • Framework agnostic (easily integrate Interserver with your favourite framework)
  • React companion package (interserver-react)

Installation

With yarn:

yarn add interserver

With npm:

npm install --save interserver

Usage

import interserver from "interserver";

const container = document.querySelector("#container");

// The handler is fired whenever `isIntersecting` changes
function handleChange(isIntersecting) {
  if (isIntersecting) {
    console.log("Container is visible!")
  }
}

const unobserve = interserver(container, handleChange);

setTimeout(unobserve, 5000);