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

photo-gallery.js

v2.3.2

Published

photo gallery javascript library

Downloads

8

Readme

Gallery.js

gallery.js is a JavaScript library for creating customizable image galleries. This library allows you to define rows of images with various configurations such as the number of columns, height, padding, alignment, hover animations, and gaps between items.

Installation

You can install the library via npm:

npm install gallery.js

Usage

Importing the Library

To use gallery.js in your project, you need to import the Row class:

import Row from 'gallery.js';

Creating a Row

You can create a new row by instantiating the Row class and passing a configuration object. The configuration object can have the following properties:

  • columns: The number of columns in the row.
  • height: The height of each item in the row (e.g., "300px").
  • gap: The gap between items (e.g., "5px").
  • padding: An object specifying the padding value and direction (e.g., { value: '10px', direction: 'x' }).
  • alignment: The vertical alignment of items in the row (e.g., "top", "bottom", "center").
  • hoverAnimation: The type of hover animation (e.g., "width", "height", "round", "combo").
  • fixedHeight: A boolean to set a fixed height for the row.
  • images: An array of image URLs to be added to the row.

Example

const rowConfig = {
  columns: 4,
  height: "300px",
  gap: "10px",
  padding: { value: "20px", direction: "x" },
  alignment: "center",
  hoverAnimation: "height",
  fixedHeight: true,
  images: [
    "image1.jpg",
    "image2.jpg",
    "image3.jpg",
    "image4.jpg"
  ]
};

const myRow = new Row(rowConfig);
document.body.appendChild(myRow.element);

API

Row Class

  • constructor(config): Initializes a new row with the given configuration.
  • addPadding(padding, direction): Adds padding to the row.
  • alignRow(direction): Aligns the items in the row vertically.
  • changeGap(gap): Changes the gap between items in the row.
  • addHoverAnimation(type): Adds hover animation to the items in the row.
  • fixRow(): Sets a fixed height for the row.
  • addImage(itemNum, url): Adds an image to a specific item in the row.

Item Class

  • constructor(height): Initializes a new item with the given height.
  • addEventListener(type): Adds an event listener for hover animations.

Configuration Details

Padding

  • value: The padding value (e.g., "10px").
  • direction: The direction of the padding. Possible values are "top", "bottom", "left", "right", "x" (horizontal), "y" (vertical).

Alignment

  • top, start, flex-start: Align items to the top.
  • bottom, end, flex-end: Align items to the bottom.
  • center, centre, middle: Align items to the center.

Hover Animations

  • width: Increase the width of the item on hover.
  • height: Increase the height of the item on hover.
  • round: Round the corners of the item on hover.
  • combo: Combination of width and height increase on hover.

Examples

Basic Example

const basicRow = new Row({
  columns: 3,
  height: "200px",
  gap: "5px",
  images: [
    "image1.jpg",
    "image2.jpg",
    "image3.jpg"
  ]
});

document.body.appendChild(basicRow.element);

Advanced Example

const advancedRow = new Row({
  columns: 5,
  height: "250px",
  gap: "10px",
  padding: { value: "15px", direction: "y" },
  alignment: "bottom",
  hoverAnimation: "combo",
  fixedHeight: true,
  images: [
    "image1.jpg",
    "image2.jpg",
    "image3.jpg",
    "image4.jpg",
    "image5.jpg"
  ]
});

document.body.appendChild(advancedRow.element);

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License.