Skip to content

Pure JS Lightbox is an open source project based on JavaScript. It's simple, mobile-friendly, has touch and swipe support and keyboard navigation. The project is licensed under the GPL-3.0 license.

License

Notifications You must be signed in to change notification settings

magnusmartin85/pure-js-lightbox

Repository files navigation

Pure JS Lightbox

Simple and lightweight JavaScript lightbox.

Features

  • Simple
  • Mobile friendly
  • Touch and swipe support
  • Keyboard navigation
  • Lightweight

Getting started

  1. Download the zip file of the latest release from GitHub. You will find HTML, JS and a CSS file inside.

  2. Include the CSS file at the top of your page in the head section: <link href="path/to/pure-js-lightbox-core.css" rel="stylesheet" />

  3. Place the script tag at the bottom of your page right before the closing body tag: <script src="path/to/pure-js-lightbox-core.js"></script>

  4. Add <img> tags with attributes to your html:

    <img
    class="preview-image"
    data-lightbox-id="nature"
    src="images/1.jpg"
    alt="Goettingen/Diemarden: Hay Bales After Mowing"
    data-photographer="© light.tales.photography by Micha Z."
    />
    
  5. Add markup for overlay:

     <div class="lightbox-overlay hidden"></div>
    
  6. Add markup for backdrop:

    <div class="lightbox-backdrop hidden"></div>
    
Attribute Required/Optional Description
class required Defaults to preview-image.
data-lightbox-id required Distinguish images between multiple image sets.
src required Relative image path. For example: images/3.jpg.
alt optional Text appears under the image.
data-photographer optional Source of the image. Appears under the image.

Local development

Installation

For installation cd into the project root and run npm install.

Development

To serve on localhost run npm run start on the command line.

Build

For a production build run npm run build on the command line. This will generate a public directory with index.html, pure-js-lightbox-core.js, pure-js-lightbox-core.css and loading-animation.svg.

Demo

Demo

Built with

TypeScript is JavaScript with syntax for types.

CSS with superpowers.

Module Bundler for JavaScript.

Demo images for the repository.

Beautiful demo images (on the demo web page).

Author

Magnus Martin

About

Pure JS Lightbox is an open source project based on JavaScript. It's simple, mobile-friendly, has touch and swipe support and keyboard navigation. The project is licensed under the GPL-3.0 license.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published