Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

14 Commits

Repository files navigation

Perplex Lightbox

Lightweight and Accessible Lightbox/Modal that supports CSS or GSAP animations out of the box.

The plugin checks if the website is already loading GSAP. If so, GSAP will be used for animations. If not, CSS-animations will be used.

Import plugin

The plugin is available as a ES-module, CommonJS-module and Universal Module (UMD).

ESM:

importLightboxfrom'../../dist/perplex.lightbox.js';

UMD:

Load this file in your HTML:

<scriptsrc="'../../dist/perplex.lightbox.umd.js"></script>

Usage

varlightboxElem=document.getElementById("lightbox");varmyLightbox=newLightbox(lightboxElem);--Inyourevent listener: --myLightbox.open();

Options

Arguments

Lightbox() takes two arguments: element and options

OptionTypeDefaultDescription
elemDOM Node or jQuery objectnullLightbox container element (required).
optionsobject{}Options for controlling animations.

Options-arguments (all optional)

OptionTypeDefaultDescription
durationNumber400Duration of the animations (in ms).
staticEaseOpenString"cubic-bezier(0.21, 0.49, 0.1, 0.99)"Easing to apply on the CSS-animation when lightbox opens.
staticEaseCloseString"ease-in"Easing to apply on the CSS-animation when lightbox closes.
gsapEaseOpenString"expo.out"Easing to apply on when lightbox opens.
gsapEaseCloseString"power1.in"Easing to apply on when lightbox closes.

Valid easings:

Methods

MethodArgumentsDescription
opennoneOpens the lightbox.
closenoneCloses the lightbox.
addCallbackcallback[function], moment[string]Adds a callback function which will be executed at a specific 'moment' in time. Valid moments are: "onOpenBegin", "onOpenEnd", "onCloseBegin", "onCloseEnd".

About

Lightweight and Accessible Lightbox that supports CSS or GSAP animations out of the box.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages