All Projects → tim-soft → React Spring Lightbox

tim-soft / React Spring Lightbox

Licence: mit
📷 A flexible image gallery lightbox with native-feeling touch gestures and buttery smooth animations, built with react-spring.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to React Spring Lightbox

Swipe Listener
Zero-dependency, minimal swipe-gesture listener for the web.
Stars: ✭ 68 (-10.53%)
Mutual labels:  gestures, touch
gestures
A library for normalized events and gesture for desktop and mobile.
Stars: ✭ 31 (-59.21%)
Mutual labels:  touch, gestures
Silentbox
A lightbox inspired Vue.js component.
Stars: ✭ 196 (+157.89%)
Mutual labels:  images, lightbox
Vue Cool Lightbox
Vue.js lightbox inspired by fancybox.
Stars: ✭ 196 (+157.89%)
Mutual labels:  images, lightbox
Vue Gallery
📷 Responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers.
Stars: ✭ 405 (+432.89%)
Mutual labels:  images, touch
fancybox
jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.
Stars: ✭ 7,261 (+9453.95%)
Mutual labels:  touch, lightbox
react-simple-image-viewer
Simple image viewer component for React
Stars: ✭ 44 (-42.11%)
Mutual labels:  images, lightbox
hes-gallery
Light, dependency free, responsive gallery script
Stars: ✭ 27 (-64.47%)
Mutual labels:  images, lightbox
Simple React Lightbox
A simple but functional light-box for React.
Stars: ✭ 265 (+248.68%)
Mutual labels:  images, lightbox
react-gallery-carousel
Mobile-friendly gallery carousel 🎠 with server side rendering, lazy loading, fullscreen, thumbnails, touch, mouse emulation, RTL, keyboard navigation and customisations.
Stars: ✭ 178 (+134.21%)
Mutual labels:  touch, lightbox
Nanogallery2
a modern photo / video gallery and lightbox [JS library]
Stars: ✭ 488 (+542.11%)
Mutual labels:  images, lightbox
React Native Swipe Gestures
4-directional swipe gestures for react-native
Stars: ✭ 471 (+519.74%)
Mutual labels:  gestures, touch
React Grid Gallery
Justified image gallery component for React
Stars: ✭ 571 (+651.32%)
Mutual labels:  images, lightbox
Whatsapp Sticker Maker
Whatsapp android sticker maker
Stars: ✭ 54 (-28.95%)
Mutual labels:  images
Yall.js
A fast, flexible, and small SEO-friendly lazy loader.
Stars: ✭ 1,163 (+1430.26%)
Mutual labels:  images
Qlimagesize
QuickLook and Spotlight plugins to display the dimensions, size and DPI of an image in the title bar instead of the filename. Also preview some unsupported formats like WebP & bpg.
Stars: ✭ 1,071 (+1309.21%)
Mutual labels:  images
Photobrowser.forms
Full screen image viewer(Xamarin.Forms) that includes "pinch to zoom" and "swipe to dismiss" gestures.
Stars: ✭ 75 (-1.32%)
Mutual labels:  images
Nativescript Fresco
This repository holds the NativeScript plugin that exposes the functionality of the Fresco image library to NativeScript developers.
Stars: ✭ 51 (-32.89%)
Mutual labels:  images
Images Web Crawler
This package is a complete tool for creating a large dataset of images (specially designed -but not only- for machine learning enthusiasts). It can crawl the web, download images, rename / resize / covert the images and merge folders..
Stars: ✭ 51 (-32.89%)
Mutual labels:  images
Lity
Lightweight, accessible and responsive lightbox.
Stars: ✭ 1,051 (+1282.89%)
Mutual labels:  lightbox

react-spring-lightbox

npm NPM npm bundle size PRs Welcome Travis (.org)

React-spring-lightbox is a flexible image gallery lightbox with native-feeling touch gestures and buttery smooth animations.


Docs     Codesandbox

✨ Features

  • ☝️    Mousewheel, swipe or click+drag to page photos
  • ⌨️  Keyboard controls Esc
  • 🐁  Ctrl + Mousewheel or Trackpad Pinch to zoom
  • 🔎  Double/Single-tap or double/single-click to zoom in/out
  • 👌    Pinch to zoom
  • 👈  Panning on zoomed-in images
  • 🏁  Highly performant spring based animations via react-spring
  • No external CSS
  • Implement your own UI
  • Supports IE 11, Edge, Safari, Chrome, Firefox and Opera
  • Full typescript support
  • Supports any <img /> attribute including loading (lazy loading), srcset and aria-*

Install

yarn add react-spring-lightbox

Usage

The images prop now accepts a list of objects whose properties can be almost any valid React <img /> prop including srcset, loading (lazy loading) and aria-* attributes.

If you use typescript, the exact type can be imported from import { ImagesListType } from 'react-spring-lightbox';

import React, { useState } from 'react';
import Lightbox, { ImagesListType } from 'react-spring-lightbox';

const images: ImagesListType = [
    {
        src:
            'https://timellenberger.com/static/blog-content/dark-mode/win10-dark-mode.jpg',
        loading: 'lazy',
        alt: 'Windows 10 Dark Mode Setting',
    },
    {
        src:
            'https://timellenberger.com/static/blog-content/dark-mode/macos-dark-mode.png',
        loading: 'lazy',
        alt: 'macOS Mojave Dark Mode Setting',
    },
    {
        src:
            'https://timellenberger.com/static/blog-content/dark-mode/android-9-dark-mode.jpg',
        loading: 'lazy',
        alt: 'Android 9.0 Dark Mode Setting',
    },
];

const CoolLightbox = () => {
    const [currentImageIndex, setCurrentIndex] = useState(0);

    const gotoPrevious = () =>
        currentImageIndex > 0 && setCurrentIndex(currentImageIndex - 1);

    const gotoNext = () =>
        currentImageIndex + 1 < images.length &&
        setCurrentIndex(currentImageIndex + 1);

    return (
        <Lightbox
            isOpen={true}
            onPrev={gotoPrevious}
            onNext={gotoNext}
            images={images}
            currentIndex={currentImageIndex}
            /* Add your own UI */
            // renderHeader={() => (<CustomHeader />)}
            // renderFooter={() => (<CustomFooter />)}
            // renderPrevButton={() => (<CustomLeftArrowButton />)}
            // renderNextButton={() => (<CustomRightArrowButton />)}
            // renderImageOverlay={() => (<ImageOverlayComponent >)}

            /* Add styling */
            // className="cool-class"
            // style={{ background: "grey" }}

            /* Handle closing */
            // onClose={handleClose}

            /* Use single or double click to zoom */
            // singleClickToZoom

            /* react-spring config for open/close animation */
            // pageTransitionConfig={{
            //   from: { transform: "scale(0.75)", opacity: 0 },
            //   enter: { transform: "scale(1)", opacity: 1 },
            //   leave: { transform: "scale(0.75)", opacity: 0 },
            //   config: { mass: 1, tension: 320, friction: 32 }
            // }}
        />
    );
};

export default CoolLightbox;

Props

Prop Description
isOpen Flag that dictates if the lightbox is open or closed
onClose Function that closes the Lightbox
onPrev Function that changes currentIndex to previous image in images
onNext Function that changes currentIndex to next image in images
currentIndex Index of image in images array that is currently shown
renderHeader A React component that renders above the image pager
renderFooter A React component that renders below the image pager
renderPrevButton A React component that is used for previous button in image pager
renderNextButton A React component that is used for next button in image pager
renderImageOverlay A React component that renders within the image stage, useful for creating UI overlays on top of the current image
singleClickToZoom Overrides the default behavior of double clicking causing an image zoom to a single click
images Array of image objects to be shown in Lightbox
className Classes are applied to the root lightbox component
style Inline styles are applied to the root lightbox component
pageTransitionConfig React-Spring useTransition config for page open/close animation

Local Development

Clone the repo

git clone https://github.com/tim-soft/react-spring-lightbox.git react-spring-lightbox
cd react-spring-lightbox

Setup symlinks

yarn link
cd example
yarn link react-spring-lightbox

Run the library in development mode

yarn start

Run the example app in development mode

cd example
yarn dev

Changes to the library code should hot reload in the demo app

License

MIT © Tim Ellenberger

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].