Lity is a ultra-lightweight, accessible and responsive lightbox plugin which supports images, iframes and inline content out of the box.
Minified and gzipped, its total footprint weights about 3kB.
All ready-to-use files are located in the
Lity can also be installed via Bower or npm.
data-lity attribute to
<a> elements for which you want the links to
be opened in a lightbox:
ImageInlineiFrame YoutubeiFrame VimeoGoogle MapsInline content
If you want to open another URI than defined in the
href attribute, just add
data-lity-target with the URI:
lity function can be either used directly to open URLs (or HTML) in a
lightbox or as an event handler.
Lity lity(string target, [Object options, [, HTMLElement|$ opener]])
target: The URL or HTML to open.
options: Options as an object of key-value pairs.
opener: The element which triggered opening the lightbox (if used as a event handler, this is automatically set to the element which triggered the event).
// Open a URL or HTML in a lightbox;;// Bind as an event handler;
If you open a lightbox programmatically, the
lity function returns a
instance you can use to interact with the lightbox.
Lity instance is also passed as the second argument to the
var instance = ;
Closes the lightbox and returns a promise which resolves once the closing animation is finished.
Returns the root HTML element.
var element = instance;
Returns the HTML element which triggered opening the lightbox.
var opener = instanceopener;
Note: The value might be undefined if the lightbox has been opened programmatically and not by a click event handler and no opener argument was provided.
Sets or returns options of the instance.
var all = instanceoptions;var template = instanceoptions'template';instanceoptions'template' '<div>...</div>';
All events receive the
Lity instance as the second
Triggered before the lightbox is opened.
Triggered when the lightbox is ready.
Triggered before the lightbox is closed.
Triggered when the closing animation is finished and just before the lightbox is removed from the DOM.
Triggered when the instance is resized, usually when the user resizes the window.
Copyright (c) 2015-2016 Jan Sorgalla. Released under the MIT license.