New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-awesome-gallery

Package Overview
Dependencies
Maintainers
0
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-awesome-gallery

Awesome gallery with Reanimated v2

  • 0.4.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21K
increased by18.76%
Maintainers
0
Weekly downloads
 
Created
Source

npm version

Support

If you love using React Native Awesome Gallery and would like to show your appreciation, you can support the project by buying me a coffee. Your support helps me keep the project alive and continuously improving. Every little bit counts!

"Buy Me A Coffee"

Basic usage
With toolbar
Loop
Gallery basic usageGallery with toolbarGallery loop

Supported features

  • Zoom to scale
  • Double tap to scale
  • Native iOS feeling (rubber effect, decay animation on pan gesture)
  • RTL support
  • Fully customizable
  • Both orientations (portrait + landscape)
  • Infinite list
  • Supports both iOS and Android.

Installation

Note: Starting from v0.3.6 using Reanimated v3 is required

First you have to follow installation instructions of Reanimated v3 and react-native-gesture-handler

yarn add react-native-awesome-gallery

Expo is supported since SDK 40. More information here

Usage

Check out an example folder for example with Expo Image

import Gallery from 'react-native-awesome-gallery';

// ...

const images = ['https://image1', 'https://image2'];

return (
  <Gallery
    data={images}
    onIndexChange={(newIndex) => {
      console.log(newIndex);
    }}
  />
);

Props

PropDescriptionTypeDefault
dataArray of items to renderT[]undefined
renderItem?Callback func which can be used to render custom image component, e.g FastImage. NOTE: You have to call setImageDimensions({width, height}) parameter after image is loaded(renderItemInfo: {item: T, index: number, setImageDimensions: Function}) => React.ReactElementundefined
keyExtractor?Callback func which provides unique keys for items(item: T, index: number) => string or numberTakes id or key or _id from Item, otherwise puts Item as key
initialIndex?The initial image indexnumber0
onIndexChange?Is called when index of active item is changed(newIndex: number) => voidundefined
numToRender?Amount of items rendered in gallery simultaneouslynumber5
emptySpaceWidth?Width of empty space between itemsnumber30
doubleTapScale?Image scale when double tap is firednumber3
doubleTapInterval?Time in milliseconds between single and double tap eventsnumber500
maxScale?Maximum scale user can set with gesturenumber6
pinchEnabled?Is pinch gesture enabledbooleantrue
swipeEnabled?Is pan gesture enabledbooleantrue
doubleTapEnabled?Is double tap enabledbooleantrue
disableTransitionOnScaledImage?Disables transition to next/previous image when scale > 1booleanfalse
hideAdjacentImagesOnScaledImage?Hides next and previous images when scale > 1booleanfalse
disableVerticalSwipe?Disables vertical swipe when scale == 1booleanfalse
disableSwipeUp?Disables swipe up when scale == 1booleanfalse
loop?Allows user to swipe infinitely. Works when data.length > 1booleanfalse
onScaleChange?Is called when scale is changed(scale: number) => voidundefined
onScaleChangeRange?Shows range of scale in which onScaleChange is called{start: number, end: number}undefined
containerDimensions?Dimensions object for the View that wraps gallery.{width: number, height: number}value returned from useWindowDimensions() hook.
style?Style of containerViewStyleundefined

Events

PropDescriptionType
onSwipeToClose()Fired when user swiped to top/bottomFunction
onTranslationYChange(translationY: number, shouldClose: boolean)'worklet'; Fired when user is swiping vertically to close the galleryWorklet
onTap()Fired when user tap on imageFunction
onDoubleTap(toScale: number)Fired when user double tap on imageFunction
onLongPress()Fired when long press is detectedFunction
onScaleStart(scale: number)Fired when pinch gesture startsFunction
onScaleEnd(scale: number)Fired when pinch gesture ends. Use case: add haptic feedback when user finished gesture with scale > maxScale or scale < 1Function
onPanStart()Fired when pan gesture startsFunction

Methods

import Gallery, { GalleryRef } from 'react-native-awesome-gallery';

// ...

const ref = useRef<GalleryRef>(null);
PropDescriptionType
setIndexSets active index(newIndex: number, animated?: boolean) => void
resetResets scale, translation(animated?: boolean) => void

License

MIT

Keywords

FAQs

Package last updated on 28 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc