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

yalb

v0.1.2

Published

Yet Another LighBox. Easy to use and out of the Box in pure JS

Downloads

5

Readme

Yalb (Vanilla)

Yet Another LightBox
Yalb only uses pure Javascript. All animations are done using css-transition or animation. If you would like to go with a jQuery-version take a look at jquery.yalb.

  • Note that Yalb (Vanilla) is using Javascript-Functions which are only available in modern browsers.
  • The Script detects transition-support and does a fallback to no animation at all (e.g. IE9)
  • IE supports no CustomEvents. Thats why a polyfill is added to the script

Getting Started

Download the production version or the development version. Or run

bower install vanilla.yalb
// yalb was already taken

Include yalb in your web page:

<link rel="stylesheet" href="dist/yalb.min.css">
<script src="dist/yalb.min.js"></script>
<script>
jQuery(function($) {

  var images = [
    'img1.jpg',
    'img2.jpg',
    'img3.jpg',
    'img4.jpg',
    'img5.jpg'
  ]

  yalb(images);

  // for other possibilities to call yalb see below

});
</script>

Documentation

Collections you can pass to Yalb / Examples

  • array filled with Strings

      var images = [
      	'img1.jpg',
      	'img2.jpg',
      	'img3.jpg',
      	'img4.jpg',
      	'img5.jpg'
      ];
    	
      yalb(images);
  • NodeList or Array of Nodes

      var images = document.getElementsByTagName('img');
      yalb(images);
    
      // or
      var links = document.getElementsByTagName('a');
      yalb(links, {src: 'href'});
    
      // or any other node with an attribute containing the path
      // e.g. <span data-image="/path/to/image.jpg"
      yalb(span, {src: 'data-image'});
  • jQuery-Collection

      var images = $('img');
      yalb(images);
    
      // or same as above
  • selfmade object containing the path

      var images = [
      	{
      		foo: 'bar'
      		path: 'path/to/image.jpg'
      	}, 
      	{
      		// and so on
      	}
      ];
    
      yalb(images, {src: 'path'});
    
      // or even
      var images = [
      	{
      		path: {
      			'to': {
      				'image': 'path/to/image.jpg'
      			}
      		}
      	},
      	{
      		// and so on
      	}
      ];
    
      yalb(images, {src: 'path.to.image'});

Options

The following options can be passed when calling yalb:

  • src ( default:'src' ), Attribute where the path is located.
  • current ( default:0 ), The image which is presented when opening yalb
  • class ( default:'yalb' ), The class passed to the html-container of yalb
  • loop ( default:true ), If true, images will be repeated when hitting the first/last image
  • open ( default:true ), If true, yalb opens when called
  • width ( default:0 ), max-with of the Yalb-window
  • height ( default:0 ), max-height of the Yalb-window

You can change the default values for the whole page by assigning to yalb.defaults

yalb.defaults = {
    src: 'src',
    current: 0,
    'class': 'yalb',
    loop: true,
    open: true,
    width: 0,
    height: 0
};

Methods

You can control the behavior of yalb with the following methods

  • yalb.open() - Opens yalb when still not open
  • yalb.close() - Close yalb; same as hitting the close-button
  • yalb.next() - Next Image; same as hitting the next-button
  • yalb.prev() - Previous Image; same as hitting the prev-button
  • yalb.show(index) - Changes to the image on position index
  • yalb.get() - Gets the node of the container on which all events are triggered

Events

You can listen to the following Events:

  • change - When the image has changed
  • open - When open is called (per Method or per yalb-call with open:true)
  • close - When close-button is pressed
  • next - When next-button is pressed
  • prev - When prev-button is pressed
  • show - When show is called

Example

var yalb_instance = yalb.get(); // or yalb_instance = yalb(); or next().next()
yalb_instance.addEventListener('next', function(){ /* do stuff */ }, false);