1.1.0 • Published 2 years ago

happygallery v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

HappyGallery

Lightweight lightbox for javascript to make developers happy :)

Installation

Install the latest version using npm:

npm install happygallery

More installation methods will be added in the future.

Usage

Import HappyGallery:

import HappyGallery from "happygallery";

Create the HTML structure:

<div id="my-happygallery">
  <a href="https://picsum.photos/seed/test1/600/400">
    <img title="Test Image 1" alt="image 1 text" src="https://picsum.photos/seed/test1/600/400" />
  </a>
  <a href="https://picsum.photos/seed/test2/600/400">
    <img title="Test Image 2" alt="image 2 text" src="https://picsum.photos/seed/test2/600/400" />
  </a>
  <a href="https://picsum.photos/seed/test3/600/400">
    <img title="Test Image 3" alt="image 3 text" src="https://picsum.photos/seed/test3/600/400" />
  </a>
  <a href="https://picsum.photos/seed/test4/600/400">
    <img title="Test Image 4" alt="image 4 text" src="https://picsum.photos/seed/test4/600/400" />
  </a>
</div>

Inside JS, initialize a new HappyGallery instance:

const myGallery = document.querySelector("#my-happygallery");
const myHappyGallery = new HappyGallery(myGallery);

For more customization, also pass an options object:

const myGallery = document.querySelector("#my-happygallery");
const myHappyGallery = new HappyGallery(myGallery, {
  itemSelector: "a",
});

Options

nametypedefault valuedescription
observebooleanfalseUse a MutationObserver to reload the gallery when the DOM is modified
updateOpenGalleryOnMutationbooleantruerequires observe Should new items be added to the open gallery
itemSelectorselector"a"Selector for where to find images. Targeted elements should be an image or contain one
slideAnimationDurationfloat0.3CSS transition duration in seconds
toolbarstring[]"download", "share"Array with toolbar buttons that should be visible
useNativeShareAPIbooleantruerequires toolbar[].sharebutton Should the share-button use the browsers native share API (if available)

Contribute

Thanks for your interest in developing HappyGallery. We're always looking forward to getting more people excited to join our project. Here are few things you should consider when contributing to HappyGallery:

  1. Before working on new features, share your idea in the discussions tab.
  2. Always format your code using npm run format before creating commits.

Help & Feedback

If you have any questions, feel free to ask in discussions. To report bugs, please head over to issues.

Contributors

Project created and maintained by

made possible by Krauss Kommunikation GmbH.