1.0.3 • Published 6 years ago

react-native-universal-image v1.0.3

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

UniversalImage

An auto sizing image component with progressive loading for react native.

Universal Image

Image component that resizes itself to contain the image. Progressively loads image with blur effect and spinner overlay.

Note: For auto resize, please make sure your thumbnails are the same aspect ratio as the original image.

Installation

Since the library is a JS-based solution, to install the latest version of react-native-universal-image you only need to run:

yarn add react-native-universal-image

or

npm install --save react-native-universal-image

Use Cases

  • Rendering remote images with variable dimensions.
  • Building a feeds / timeline screen ?
  • Leverage progressive loading for a performant UI.
  • Looking for an instagram like animation for your images ?
  • Default resize modes (cover / contain) don't provide what you are looking for?

Usage

import UniversalImage from 'react-native-universal-image';

<UniversalImage
    indicator
    indicatorColor="#1AD2EF"
    indicatorSize="large"
    defaultHeight={350}
    imageFadeDuration={3000}
    thumbnailFadeDuration={1000}
    thumbnailBlurRadius={1}
    imageSource={{ uri: IMAGE_URL }}
    thumbnailSource={{ uri: THUMBNAIL_URL }} />

Properties

PropDescriptionDefaultRequired
indicatorSpinner overlay on imagefalse
indicatorColorColor of spinner componentNone
indicatorSizeSize of spinner component ('small', 'large')None
defaultHeightDefault height of the component while the thumbnail is being loaded350
thumbnailSourceProvide a low resolution version of the image used in imageSource.NoneRequired
imageSourceOriginal image uriNoneRequired
thumbnailBlurRadiusBlur radius for the low resolution thumbnail.None
imageFadeDurationFade-in duration for the image in ms.None
thumbnailFadeDurationFade-in duration for the thumbnail in ms.None
onLoadThumbnailCallback function that gets called when the thumbnail is loaded.noop
onLoadImageCallback function that gets called when the main image is loaded.noop

Contributing

Interested in contributing to this repo? Feel free to raise a pull request or report an issue at react-native-universal-image.