• Stars
    star
    155
  • Rank 233,347 (Top 5 %)
  • Language
    JavaScript
  • Created almost 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lightbox for react with zoom, rotate and move feature with touch support 💡📦

Lightbox-like Image viewer for React

Lightbox image image viewer for react with zoom, rotate and move feature with single or multi image. Includes basic touch support.

🚀See it in Action

imgur

Features

  • Fully Responsive
  • Smooth tranformation
  • Single Image Mode
  • Multiple Image Mode
  • Virtually unlimited zoom steps and move Support
  • Full 360 degree rotate support
  • Touch Support
  • Full keyboard support
  • Supports all major browsers

How to use

Setting up

To install, run the following command with your favourite package manager:

yarn add react-awesome-lightbox

Once installed, include it in your project like this:

import Lightbox from "react-awesome-lightbox";
// You need to import the CSS only once
import "react-awesome-lightbox/build/style.css";

Then use it like this for single image:

<Lightbox image="image_url" title="Image Title">

or for multiple images:

let images = [
    {
        url:"image_url1",
        title:"image title 1"
    },
    {
        url:"image_url2",
        title:"image title 2"
    }
]
<Lightbox images={images}>

Available properties

Lightbox can be customized with the following properties

property default description
image n/a URL to the image to show
while in single image mode
title n/a Title to show with the single image
images null Takes an array of inage
and starts the lightbox
in multi image mode. *If you supply both image and
images prop, image is ignored.
supported formats : ["url1","url2"...]
or
[{url"url",title:"title"}...]
startIndex 0 If the lightbox is in multiple image mode,
the starting image index
zoomStep 0.3 Step for zoom in or zoom out,
1 means 100% so, default 0.3 means 30%
onClose null This function determines how to
react when the close button is pressed
allowZoom true Determines if image zoom controls should be shown
allowRotate true Determine if image rotate controls should be shown
allowReset true Determine if reset buttons should be shown
buttonAlign "flex-end" Determine how to align the toolbar buttons
options are: flex-end, flex-start, center
showTitle true Determines if title should be shown if available
keyboardInteraction true Determine if keyboard shortcuts will be allowed
See below section for available
Shortcuts
doubleClickZoom 4 Determine how much to zoom in if double clicked.
default 4 means close to 400%.
Setting it to 0 will disable
doubleclick/ double tap zoom
onNavigateImage null Callback when image is navigated. It accepts the
new index as its parameter.

Keyboard Shortcut:

  • Arrow keys , , when zoomed out, will navigate between images in multi image mode.
  • When Zoomed in, , , , keys will move the image
  • + and - will zoom in and out the image is zoom is allowed.
  • esc will reset transformation (if reset is allowrd), if no transformation is left to reset it will trigger the onClose function (close the lightbox).

Styling

All the styles are in the build/style.css file. If you want to modify the CSS, download this file and customize it. then include the custom CSS file instead of the file from the package.

Todo:

  • Pinch to Zoom

Released under the MIT license. Icons are from Icofont. Contributions are welcome 🖤

More Repositories

1

react-native-docker

Docker image to develop and Build react-native application 🐳🚀
Dockerfile
77
star
2

otp-without-db

database less OTP verification using cryptography 🔐
JavaScript
73
star
3

css-only-loaders

A collection of animated loaders made with pure CSS and 🖤
JavaScript
62
star
4

webaudio-oscilloscope

A highly customizable oscilloscope for Web Audio 🔈 🎤
JavaScript
60
star
5

pushkit

All the required components to set up independent web push notifications 🎈
JavaScript
56
star
6

evileval

A small and highly experimental 😈 JavaScript repl'ish system for doing live coding presentation
JavaScript
27
star
7

pochaslider

Multipurpose CSS3 slider / Presentation framework ✨
JavaScript
25
star
8

docker-apktool

Docker image for Latest Apktool 🛠
Dockerfile
18
star
9

react-icofont

React Wrapper for the icofont project 🕶
HTML
17
star
10

webrtc-test-suite

Capability testing and Tools for WebRTC 📹 🎤 🔬
JavaScript
12
star
11

webChef

Very very minimal client side template engine inspired by erb / ejs syntax 👨🏻‍🍳(Use ES6 String literals instead)
JavaScript
8
star
12

react-simple-conditional

Conditional Rendering component in React
JavaScript
8
star
13

notzero

Browser extension for bypassing 0.facebook.com error 🤦‍♂️ 🤟🏾
JavaScript
8
star
14

pochani

Create Presentations from the command line with Markdown. Power by PochaSlider
CSS
7
star
15

lwhh-fullstackJS-project

LWHH এর ফুলস্ট্যাক জাভাস্ক্রিপ্ট কোর্সের স্যাম্পল প্রোজেক্ট
JavaScript
6
star
16

webaudio-guitar-tuner

A guitar tuner fun project using web audio API
JavaScript
3
star
17

manifestgen

Manifest Generator for Firefox OS Apps
HTML
2
star
18

mouseparallax

Simple parallax mouse effect with jQuery
JavaScript
2
star
19

orin.js

jQuery lightbox with Cool background effect
JavaScript
1
star