Lity ==== 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. It requires [jQuery](https://jquery.com) or [Zepto](http://zeptojs.com) (with the [callbacks](https://github.com/madrobby/zepto/blob/master/src/callbacks.js), [deferred](https://github.com/madrobby/zepto/blob/master/src/deferred.js) and [data](https://github.com/madrobby/zepto/blob/master/src/data.js) modules). Installation ------------ All ready-to-use files are located in the [`dist/`](dist/) directory. Include the Lity javascript and css files and its dependencies in your HTML document: ```html ``` Lity can also be installed via Bower or [npm](https://www.npmjs.com/package/lity). Usage ----- ### Declarative Add the `data-lity` attribute to `` elements for which you want the links to be opened in a lightbox: ```html Image Inline iFrame Youtube iFrame Vimeo Google Maps
Some content to show...
'); // Bind as an event handler $(document).on('click', '[data-my-lightbox]', lity); ``` The Lity instance ----------------- If you open a lightbox programmatically, the `lity` function returns a `Lity` instance you can use to interact with the lightbox. The `Lity` instance is also passed as the second argument to the [event handlers](#events). ```javascript var instance = lity('https://www.youtube.com/watch?v=XSGBVzeBUbk'); ``` ### API * [Lity.close](#lityclose) * [Lity.element](#lityelement) * [Lity.opener](#lityopener) * [Lity.options](#lityoptions) #### Lity.close Closes the lightbox and returns a promise which resolves once the closing animation is finished. ```javascript instance.close().then(function() { console.log('Lightbox closed'); }); ``` #### Lity.element Returns the root HTML element. ```javascript var element = instance.element(); ``` #### Lity.opener Returns the HTML element which triggered opening the lightbox. ```javascript var opener = instance.opener(); ``` **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. #### Lity.options Sets or returns options of the instance. ```javascript var allOptions = instance.options(); var template = instance.options('template'); instance.options('template', '