0.1.19 • Published 12 months ago

highlight-overlay-js v0.1.19

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

Highlight Overlay

This is a tiny vanilla JavaScript library that can be used to apply overlays with highlighted areas on web pages. It is not tied to any particular framework and can be easily integrated into any framework.

Showcases

As flexible as you needAvailable on any html element
Alt As flexible as you needAlt As flexible as you need
Alt As flexible as you needAlt As flexible as you need

Usage

// Create an instance of overlay
const highlightOverlay = new HighlightOverlay();

// Show the overlay
highlightOverlay.show(document.querySelectorAll(`#element-1, #element-2`));

// In case the cloing is controlled by consumer:
highlightOverlay.hide();
  import React from 'react';
  import HighlightOverlay from 'highlight-overlay-js';
  
  const highlightOverlay = new HighlightOverlay();
  
  export const HyHeader: React.FC = () => (
      <div>
          <h1 id="myHeader">My header title</h1>
  
          <button onClick={() => highlightOverlay.show(document.querySelectorAll('#myHeader'))}>Highlight</button>
      </div>
  )
  
  highlightOverlay.show(document.querySelectorAll('#myHeader'));

Methods

MethodDescription
showIs required to provide a list of elements to which highlight should be applied.
hideMethod used for controlled hiding of overlay.

Parameters

NameDefault valueTypeDescription
offset3numberDefines transparent area's offset size.
closeCloseTypes.ALWAYSCloseTypesDefines closing logic behavior.
backDropColor0, 0, 0, 0.3number[]Defines overlay color. Is required to use rgba format.
duration100numberDefines overlay animation duration in MS.
cursor.enabledfalsebooleanEnables cursor highlight.
cursor.size15numberDefines radius size of cursor highlight.

Enums

NameValueDescription
CloseTypesBACKDROPCloses overlay when click is clicked on non-transparent area
ALWAYSCloses overlay on any click
NONEIgnores any click and persists overlay till is closed manually

Todos

  • Clear cursor position after losing screen view port
0.1.19

12 months ago

0.1.18

1 year ago

0.1.17

1 year ago

0.1.16

1 year ago

0.1.15

1 year ago

0.1.14

1 year ago

0.1.13

1 year ago