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

pxgallery

v1.0.0

Published

A easy to use javascript plugin for different image layouts.

Downloads

4

Readme

Description

PXGallery is a library which can set different layouts in pure javascript without any dependencies.

Demo

Demo

Setup

Easy setup

Commonly, you can just install it with a css and javascript:

<link rel="stylesheet" href="css/pxgallery.min.css">

Include the Gallery script at the bottom of the body of your webpage:

<script src="js/pxgallery.js">

And then, set the image and the layouts:

var pxgallery = new pxgallery();
pxgallery.setImage([
    "http://placehold.it/1300x1600/E97452/fff",
    "http://placehold.it/1300x1300/4C6EB4/fff",
    "http://placehold.it/1300x1250/449F93/fff",
    "http://placehold.it/800x400/936FBC/fff",
    "http://placehold.it/1000x500/D25064/fff"
],
{
    layout: 4,
    fullscreenState: true,
});

Module setup

You can also use module to include the library just like the demo above, here are some examples:

ES 6

import pxgallery from 'lib/pxgallery.js'

AMD

requirejs(['pxgallery'], function( pxgallery ) {
    // some code here
});

Options

Here are defalut options:

When new an object:

var pxgallery = new pxgallery({
  containerSelector:  '.pxgalleryContainer',
  fullscreenSelector: '.pxfullscreen',
  boxSelector:        '.pxgalleryBox'
})

When set the images:

pxgallery.setImage({

    layout:           2,
    puzzleHeight:     400,
    fullscreenState:  true,
    column:           5,
    heightMin:        150,
    mdSquareSize:     3,
    smSquareSize:     6,
    gutter:           10
})

Available layouts:

 this.layout = {
      NONE: 0,      // no layout
      PUZZLE: 1,    // puzzle layout
      WATERFALL: 2, // waterfall layout
      BARREL: 3,    // barrel layout
      SQUARE: 4     // square layout
    };

API

/**
  * init the album
  * It will replace the photos
  * @param {(Stirng | String[])} image - the URL of the photo or the URL array of the photos
  * @param {Object} opts - layout options
  */

pxgallery.setImage();


/**
  * get the DOM elements which contain the images
  * @return {HTMLelement[]} boxes
  */

pxgallery.getImageDomElements();

/**
  * add images to the container
  * @param {(String | String[])} image - the URL of the photo or the URL array of the photos
  * @param {Boolean} raw - weather add the images to the container directly  or not
  */

pxgallery.addImage();

/**
  * remove the images
  * @param {(HTMLelement|HTMLelement[])} image - the images that need to be removed
  */

pxgallery.removeImage();

/**
  * set the layout
  * @param {Number} - layoutValue
  */

pxgallery.setLayout();

/**
  * get current layout
  * @return {Number} -_options.layout
  */

pxgallery.getLayout();

/**
  * clear the layouts
  */

pxgallery.clearLayout();

/**
  * NOT RECOMMAND, it may effect the perfomance of the browser cause it change the DOM directly
  * set the gutter between images
  * @param {Number} - gutter
  */

pxgallery.setGutter();

/**
  * enable fullscreen
  */

pxgallery.enableFullscreen() ;

/**
  * disable fullscreen
  */

pxgallery.disableFullscreen();

/**
  * @return {Boolean} weather eenable fullscreen view
  */

pxgallery.isFullscreenEnabled();

/**
  * set the 2nd image square
  * @param {Number} length -the number of the images
  */

pxgallery.setPuzzleSquare();

/**
  * NOT RECOMMAND, it may effect the perfomance of the browser cause it change the DOM directly
  * set the height of the container
  * @param {Number} - height
  */

pxgallery.setPuzzleHeight();

/**
  * NOT RECOMMAND, it may effect the perfomance of the browser cause it change the DOM directly
  * set the number of the column
  * @param {NUmber} - columnNum
  */

pxgallery.setColumnNum();

/**
  * init the waterfall column only after clear the columns inside the container
  * @param {NUmber} - columnNum
  */

pxgallery.initWaterfallColumn();

/**
  * get minimun height index of the column
  * @return {Number} - index
  */

pxgallery.getWaterfallHeightMin();

/**
  * initaialize the barrel layout
  * @param {Object} - row, a row object which contain height
  */

pxgallery.initBarrelBin();

/**
  * calculate the ratio
  * @return {Object} - rows
  */

pxgallery.setBarrelBin();

/**
  * NOT RECOMMAND, it may effect the perfomance of the browser cause it change the DOM directly
  * set the height of the barrel
  * @param {Number} - min
  */
pxgallery.setBarrelHeight();

/**
  * NOT RECOMMAND, it may effect the perfomance of the browser cause it change the DOM directly
  * Set the suqare size when over 768 px
  * @param {Number} size - (1-12)
  */

pxgallery.setMdSquareSize();

/**
  * NOT RECOMMAND, it may effect the perfomance of the browser cause it change the DOM directly
  * Set the suqare size when under 768 px
  * @param {Number} size - (1-12)
  */

pxgallery.setSmSquareSize();

License

Released under the MIT license.