Iris-Out Demo

Click on any card to highlight it with the iris-out effect, or use the controls below.

GitHub npm package

Usage Instructions

Iris-Out is a lightweight library for highlighting DOM elements by shading everything else on the page.

Installation

npm install @nikitindiz/iris-out

Basic Usage

// Initialize with default options
const iris = new IrisOut();

// Highlight a specific element
const elementToHighlight = document.getElementById('my-element');
iris.highlight(elementToHighlight);

// Remove the highlight when done
iris.clear();

With Callbacks

// Highlight with callbacks
iris.highlight(
  elementToHighlight,
  // Update callback - called whenever the cutout position changes
  (rect) => {
    console.log('Element position updated:', rect);
  },
  // Clear callback - called when the highlight is cleared
  () => {
    console.log('Highlight was cleared');
  }
);

Custom Options

const iris = new IrisOut({
  backgroundColor: 'rgba(0, 0, 0, 0.7)', // Background color of the overlay
  opacity: 0.7,                          // Opacity of the overlay
  zIndex: 9999,                          // z-index of the overlay
  fadeDuration: 300,                     // Duration of animation in milliseconds
});

Controls

Settings

0.7

Callback Demo

Callback events will appear here

Card 1

This is the first card. Click to highlight it.

Card 2

This is the second card. Click to highlight it.

Card 3

This is the third card. Click to highlight it.

Card 4

This is the fourth card. Click to highlight it.

Card 5

This is the fifth card. Click to highlight it.

Card 6

This is the sixth card. Click to highlight it.

Card 7

This is the seventh card. Click to highlight it.

Card 8

This is the eighth card. Click to highlight it.