3.2.3 • Published 4 years ago

react-native-auto-image v3.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

react-native-auto-crossAxisSize-image

Initialized by vivaxy/gt-npm-package

NPM Version NPM Downloads MIT License Conventional Commits Financial Contributors on Open Collective

This component provides you a simple way to load a remote image and automatically set Image crossAxisSize to the image dimension which fits the provided mainAxisSize.

ReactNative Image component needs users to set both mainAxisSize and crossAxisSize props.

Installation

yarn add react-native-auto-crossAxisSize-image

npm install react-native-auto-crossAxisSize-image

Usage

Use local or remote files:

import React, { Component } from 'react';
import AutoImage from 'react-native-auto-crossAxisSize-image';

import image from 'gallifrey-falls.png';

export default class Demo extends Component {
  render() {
    return (
      <View>

        <AutoImage
          mainAxisSize={100}
          source={image}
        />

        <AutoImage
          mainAxisSize={100}
          source={{uri: 'http://placehold.it/350x150'}}
        />

      </View>
    );
  }
}

You can even specify fallback images for when the source fails to load:

import React, { Component } from 'react';
import AutoImage from 'react-native-auto-crossAxisSize-image';

import image from 'gallifrey-falls.png';

export default class Demo extends Component {
  render() {
    return (
      <AutoImage
        mainAxisSize={100}
        source={{uri: 'https://vivaxy.github.io/404'}}
        fallbackSource={image}
      />
    );
  }
}

Props

nametypeisRequireddefaultdescription
mainAxisSizenumberN/Aimage mainAxisSize to fit
maxCrossAxisSizenumberInfinityimage max crossAxisSize
sourcenumber or objectN/Alocal (i.e. require/import) or remote image ({uri: '...'})
fallbackSourcenumber or objectN/Alocal (i.e. require/import) or remote image ({uri: '...'})
onCrossAxisSizeChangefunc(crossAxisSize) => {}called when updating image crossAxisSize, the argument crossAxisSize might be 0
animatedboolfalseUse Animated.Image instead of Image

Other image props except resizeMode are accepted.

Change Log

Change log

Contributing

Contributing

Licence

MIT

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

Related Projects