Giter Club home page Giter Club logo

react-native-scaled-image's Introduction

React Native Scaled Image

React Native Scaled Image is a wrapper of Image. With it, you can add images without the need to define both height or width. The dimensions are calculated automatically using the height or width provided to keep the aspect ratio of the image.

Installation

npm install react-native-scaled-image

How to use

Local images, passing only height:

import { Component } from 'react';
import ScaledImage from 'react-native-scaled-image';

const localImage = require('images/local-image.png');

class CustomView extends Component {

  render() {
    return (
      <ScaledImage source={localImage} height={100} />
    );
  }
}

Local images, passing only width:

import { Component } from 'react';
import ScaledImage from 'react-native-scaled-image';

const localImage = require('images/local-image.png');

class CustomView extends Component {

  render() {
    return (
      <ScaledImage source={localImage} width={200} />
    );
  }
}

Remote images:

import { Component } from 'react';
import ScaledImage from 'react-native-scaled-image';

const remoteImage = {uri: 'http://facebook.github.io/react-native/img/header_logo.png'};

class CustomView extends Component {

  render() {
    return (
      <ScaledImage source={remoteImage} width={200} />
    );
  }
}

Attributes

Name Type Required Description
source ImageSourcePropType/object true This is the actual image that will be shown
height number false The wanted height for the image
width number false The wanted width for the image
style object false The styles used to modify the image, the accepted attributes are the same as Image

react-native-scaled-image's People

Contributors

germanst avatar jalessandro avatar wangjoshuah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-scaled-image's Issues

maxWidth or maxHeight

A beneficial addition would be the inclusion of maxWidth or maxHeight. Currently if you have a ScrollView of image assets, you cannot assign a maxWidth correctly. This proves problematic if you want to set a series of images to a specific height and have them dynamical resize, but restrict the resize to a maximum value (i.e. logos with vastly different dimensions).

Is there a way to accomplish this?

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.