Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

react-native-auto-dimensions-image

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-auto-dimensions-image

This component can adjust the dimensions according to the given height or width. Both dimensions can be set for any local or server image

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
243
-16.49%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-auto-dimensions-image

This component can adjust the dimensions according to the given height or width. Both dimensions can be set for any local or server image

Installation

npm i react-native-auto-dimensions-image

Usage

import React, {Component} from 'react';
import {View, StyleSheet} from 'react-native';

import AutoDimensionImage from 'react-native-auto-dimensions-image';

export default class Test extends Component {
  render() {
    return (
      <View>
        {/* Remote image URL */}
        <AutoDimensionImage
          source={{
            uri: 'https://images.unsplash.com/photo-1616455579100-2ceaa4eb2d37?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8Ym13JTIwY2FyfGVufDB8fDB8fA%3D%3D&w=1000&q=80'
          }}
          dimensionType="height"
          dimensionValue={350}
          otherDimensionMaxValue={200}
          style={styles.image}
          defaultImageProps={{blurRadius: 10}}
        />

        {/* Local image URL */}
        <AutoDimensionImage
          source={require('./X5ModelImage.jpeg')}
          dimensionType="height"
          dimensionValue={200}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  image: {
    alignSelf: 'center',
  },
});

Dimension change according to the input params (width & height)

Simulator Screen Recording - iPhone 12 - 2022-04-04 at 03 59 19

Adding otherDimensionMaxValue

By adding this, we can add maximum limit to the dynamic dimension which gets changed according to the constant dynamic value (dimensionValue)

Simulator Screen Recording - iPhone 12 - 2022-04-04 at 04 01 07

Props

nametypeisRequireddefaultdescription
dimensionTypeenum('width', 'height')YES-Mention the constant dimension. (width/height)
dimensionValuenumberYES-Constant dimension value
sourceImageSourceYES-The image source (either a remote URL or a local file resource)
otherDimensionMaxValuenumberNO-Can set the maximum value for the other dimension. If that value exceeds when setting the value for constant dimension, the image will fit to the given otherDimensionMaxValue value
styleImage Style PropsNO{}Image styling
defaultImagePropsObjectNO{}The default props available in Image

Keywords

react-native

FAQs

Package last updated on 18 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts