npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-awesome-gallery

v0.4.2

Published

Awesome gallery with Reanimated v2

Downloads

58,435

Readme

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"

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

| Prop | Description | Type | Default | |----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------| | data | Array of items to render | T[] | 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.ReactElement | undefined | | keyExtractor? | Callback func which provides unique keys for items | (item: T, index: number) => string or number | Takes id or key or _id from Item, otherwise puts Item as key | | initialIndex? | The initial image index | number | 0 | | onIndexChange? | Is called when index of active item is changed | (newIndex: number) => void | undefined | | numToRender? | Amount of items rendered in gallery simultaneously | number | 5 | | emptySpaceWidth? | Width of empty space between items | number | 30 | | doubleTapScale? | Image scale when double tap is fired | number | 3 | | doubleTapInterval? | Time in milliseconds between single and double tap events | number | 500 | | maxScale? | Maximum scale user can set with gesture | number | 6 | | pinchEnabled? | Is pinch gesture enabled | boolean | true | | swipeEnabled? | Is pan gesture enabled | boolean | true | | doubleTapEnabled? | Is double tap enabled | boolean | true | | disableTransitionOnScaledImage? | Disables transition to next/previous image when scale > 1 | boolean | false | | hideAdjacentImagesOnScaledImage? | Hides next and previous images when scale > 1 | boolean | false | | disableVerticalSwipe? | Disables vertical swipe when scale == 1 | boolean | false | | disableSwipeUp? | Disables swipe up when scale == 1 | boolean | false | | loop? | Allows user to swipe infinitely. Works when data.length > 1 | boolean | false | | onScaleChange? | Is called when scale is changed | (scale: number) => void | undefined | | 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 container | ViewStyle | undefined |

Events

| Prop | Description | Type | |------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|------------| | onSwipeToClose() | Fired when user swiped to top/bottom | Function | | onTranslationYChange(translationY: number, shouldClose: boolean) | 'worklet'; Fired when user is swiping vertically to close the gallery | Worklet | | onTap() | Fired when user tap on image | Function | | onDoubleTap(toScale: number) | Fired when user double tap on image | Function | | onLongPress() | Fired when long press is detected | Function | | onScaleStart(scale: number) | Fired when pinch gesture starts | Function | | onScaleEnd(scale: number) | Fired when pinch gesture ends. Use case: add haptic feedback when user finished gesture with scale > maxScale or scale < 1 | Function | | onPanStart() | Fired when pan gesture starts | Function |

Methods

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

// ...

const ref = useRef<GalleryRef>(null);

| Prop | Description | Type | |----------|---------------------------|--------------------------------------------------| | setIndex | Sets active index | (newIndex: number, animated?: boolean) => void | | reset | Resets scale, translation | (animated?: boolean) => void |

License

MIT