npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

img-lightbox

v0.2.6

Published

Responsive no-jQuery pure JS/CSS Lightbox for images, no dependencies, 10kb unminified source code, with demo

Downloads

441

Readme

img-lightbox

Responsive no-jQuery pure JS/CSS Lightbox for images, no dependencies, 10kb unminified source code, with demo

npm Build Status Codacy Badge jsdelivr

Demo

codepen jsfiddle jsbin

Features

  • Simple initialization
  • SPA / PWA friendly: prevents multiple same events assigning
  • Debounced launch, default 500ms, custom rate can be set with rate property of options object
  • Preloading spinner that is unset after onload event succeeds
  • Pure CSS Retina Ready UI images, no external ones (prompted by github.com/jasomdotnet, thanks)
  • Custom event callbacks

CDN

jsDelivr

https://cdn.jsdelivr.net/gh/englishextra/img-lightbox@latest/js/img-lightbox.min.js https://cdn.jsdelivr.net/gh/englishextra/img-lightbox@latest/css/img-lightbox.min.css

unpkg

https://unpkg.com/img-lightbox@latest/js/img-lightbox.js https://unpkg.com/img-lightbox@latest/css/img-lightbox.css

Install

npm

npm install img-lightbox

Setup

class is required, and can be any class name you choose (in this demo it's img-lightbox-link). data-src is another method to get the source URL when you do not want the link to lead to some real URL. href is required, and contains URL of your image. For those who don't use 3rd-party scripts that interfere with links behaviour and don't force window.location they have no need in either data-touch="true" or {touch: true}. When you have scripts that interfere, then to keep lightbox working, use {touch: true} or data-touch="true" (you shouldn't enable this touch override if you have a full screen image in a lighbox link and have no other space to scroll down). data-src or href doesn't matter. Build Status

<a href="https://farm1.staticflickr.com/955/27854475488_4f2b7f52e4_k.jpg"
class="img-lightbox-link"
data-src="https://farm1.staticflickr.com/955/27854475488_4f2b7f52e4_k.jpg"
aria-hidden="true"
rel="lightbox"><img src="https://farm1.staticflickr.com/955/27854475488_5f82a379ca_z.jpg" alt="Image Lightbox" /></a>

Initialize

imgLightbox("img-lightbox-link");

Tips

SPA / PWA developers don't need to bother: work-related class is added to a link. That way you avoid multiple assignments to a single element.

Examples of event handling

(function(root) {
  "use strict";
  if (root.imgLightbox) {
    imgLightbox("img-lightbox-link", {
      onCreated: function() {
        /* show your preloader */
      },
      onLoaded: function() {
        /* hide your preloader */
      },
      onError: function() {
        /* hide your preloader */
      },
      onClosed: function() {
        /* hide your preloader */
      },
      rate: 500 /* default: 500 */,
      touch: false /* default: false - use with care for responsive images in links on vertical mobile screens */
    });
  }
})("undefined" !== typeof window ? window : this);

GitHub

englishextra/img-lightbox

License

Available under MIT license.