Skip to content

KostasSliazas/K7

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

image gallery

License Stars Forks Issues Last Commit

Table of Contents

Description

Simple image gallery built with vanilla JavaScript (~7KB) (JS+CSS)

Features

  • Responsive Design: Works seamlessly on all screen sizes, from mobile to desktop.
  • Keyboard Navigation: Navigate through images using keyboard arrow keys for a more interactive experience.
  • Download Button: Users can easily download the gallery images with a click of a button.
  • Autoplay Button: Automatically cycle through images when the autoplay button is clicked.

Installation

Include the script inside the head tag using the defer attribute,
or place it just before the closing </body> tag for optimal loading.

<script defer src="src/k7.min.js?v=7"></script>

Usage

Add class images to parent element or all images will be selected.

<div class="images">
  <img src="photos/photo01.webp" loading="lazy" alt="photo01">
</div>

Configuration

To override the default extension, add a data-ext attribute to the tag:

<img src="photos/photo16.webp" loading="lazy" alt="photo16" data-ext="webp">

This replaces the default .jpg extension with .webp for higher-resolution loading. If the data-ext attribute is set, it overrides the default extension. If not, the extensions should match (e.g., .jpg remains .jpg).

CSS background colors, update the CSS variables like so:

:root { --color1: #ee7; --color2: #777; }

CSS is encoded in Base64, which typically increases the file size. However, the CSS file is still included and can be separated from the JavaScript.

Note: There's no need to include a separate stylesheet; all styles are managed directly in JavaScript.

Build

google-closure-compiler -O ADVANCED k7.js --js_output_file k7.min.js

License

This project is licensed under the MIT License.

Contributing

To contribute, please fork this repository, create a new branch, and submit a pull request.

Clone:

git clone https://github.com/KostasSliazas/K7

Contributors

Author

Kostas Šliažas

About

Simple Image Gallery - Vanilla JavaScript (Fullscreen & Swipe Support)

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •