# smart-image-gallery

> Shows on click found by selector images in the pop-up window

Latest version **1.1.2** (published 2023-07-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install smart-image-gallery
pnpm add smart-image-gallery
yarn add smart-image-gallery
bun add smart-image-gallery
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2023-07-21 |
| First published | 2023-07-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | GaronCode |
| Maintainers | garoncode |
| Keywords | images, gallery, pop-up, standalone, easy, import |

## Links

- npm: https://www.npmjs.com/package/smart-image-gallery
- Repository: https://github.com/GaronCode/smart-image-gallery
- Homepage: https://github.com/GaronCode/smart-image-gallery#readme
- Issues: https://github.com/GaronCode/smart-image-gallery/issues
- npm.io page: https://npm.io/package/smart-image-gallery

## Dependencies (1)

- [smart-swipe-controller](https://npm.io/package/smart-swipe-controller.md) ^0.1.3

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2023-07-21
- 1.1.1 — 2023-07-21
- 1.1.0 — 2023-07-21

## README

# Smart Image Gallery
Creates a pop-up gallery when an image is clicked. Images are collected by a selector.
## [Live preview](https://garoncode.github.io/smart-image-gallery/)
## Usage
1. place images on the page in any way. You need to make sure that there is a unique CSS selector to search them
   
2. **Include Gallery**.
    If you want use as:
    - via **NPM**
    install package
    ```bash
    npm i smart-image-gallery
    ```
    include
    ```js
    import { SmartImageGallery } from "smart-image-gallery";
    ```
    - **module**
    copy file from dist folder to your project (full or minify version)
    ```html
    <script type="module">
    // for minify version 
    // import { SmartImageGallery } from "./smartImageGallery.esm.mini.js";

    import { SmartImageGallery } from "./smartImageGallery.esm.js";
    </script>
    ```
    - **iife-style** (you need use global object `SIG`)
    ```html
    <!--
        For minify version
        <script src="smartImageGallery.iife.mini.js"></script>
    -->
    <script src="smartImageGallery.iife.js"></script>
    ```
3. Setting up the gallery (object **Settings**)
   (default settings)
    ```js
    const Settings = {
        //  selector a place for embedding a modal window
        containerSelector: "body", 
        // selector to search for displayed images
        imagesSelector: ".gallery img", 
        // flag for displaying the download button
        showDownloadButton: false,
        // flag for displaying copies of images (a copy is determined by an identical src)
        displayCopies: false,
        // transition speed (0 - no transitions)
        animationDuration: 0.3,
        // flag for initializing all handlers and events at once when creating
        init: true,
    }
    // if you use iife import
    // const Gallery = new SIG.SmartImageGallery( Settings );
    const Gallery = new SmartImageGallery( Settings );
    ```
    If there was no initialization during creation, you need to use the method `init` (`Gallery.init()`)

5. If you want change styles, you can change classes before init
    ```js
    const Gallery = new SmartImageGallery({ init: false, showDownloadButton: true });

    const {imageContainer, download} = Gallery.modalElements
    imageContainer.class += " my-addition-class-name"; // addition class for image container (add space before class name)
    download.class = "my-new-class-name"; // new class for download button

    Gallery.init();
    ```
    it has several modal blocks:
        - _imageContainer_: image container div
        - _prev_: previous image button
        - _next_: next image button
        - _download_: download image button
6. Done. When you click on the image, a window should appear.


## Methods
| method | action |
| --- | --- |
| hide() | hide modal |
| prev() | show previous img |
| next() | show next img |
| init() | initialization of handlers and events for script |

## Addition Events
On `document.body` script triggers the following events:
- **smartgalleryopen**:  on open
- **smartgalleryclose**: on close
Usage example:
```js
document.body.addEventListener("smartgalleryopen", () =>
    ...
);

document.body.addEventListener("smartgalleryclose", () =>
    ...
);
```

---
_Source: https://npm.io/package/smart-image-gallery · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
