Coder Social home page Coder Social logo

pro-image's Introduction

ProImage

React native progressive image component.

Install

$ npm i pro-image
or
$ yarn add pro-image

Usage

Simple example:

import ProImage from 'pro-image';

const MyImageComponent = () =>
  <ProImage 
    thumbnail={{ uri: 'lorem.ipsum/thumbnail.png' }} 
    image={{ uri: 'lorem.ipsum/big-image.png' }} 
  />

Properties

Property Is optional? Default Description
image no - Image to render.
thumbnail yes null The image to render with the same aspect ratio and the smallest resollution possible.
placeholder yes null Placeholder image to render while the image is loading.
(Note: placeholder will not show if there's a thumbnail)
resizeMode yes cover Image resize mode.
style yes {} Styles for the image.
containerStyle yes {} Styles for the image container (View).
duration yes 1000 (ms) Time in milliseconds that the fade effects lasts.

Full example:

import ProImage from 'pro-image';
import placeholder from './path/to/placeholder.png';

const MyImageComponent = () =>
  <ProImage
    placeholder={placeholder}
    thumbnail={{ uri: 'lorem.ipsum/thumbnail.png' }}
    image={{ uri: 'lorem.ipsum/big-image.png' }}
    containerStyle={{ margin: 4 }}
    style={{ height: 100, width: 200 }}
    resizeMode="contain"
/>

Global properties

Set global values to all the images in your app.

Properties

Property Defalut Description
duration 1000 (ms) Time in milliseconds that the fade effects lasts.
placeholder null Placeholder image.
blur 1 Blur radius for the thumbnail.

Usage

Customize all options:

import ProImage from 'pro-image';
import placeholder from './path/to/placeholder.png';

ProImage.setDefaultConfig({
  duration: 500, 
  placeholder, 
  blur: 2
});

Changing just one value:

import ProImage from 'pro-image';
ProImage.setDefaultConfig({ duration: 750 });

pro-image's People

Contributors

martincarrera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.