npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-full-ratio-image

v1.0.3

Published

擴充 Image 組件,提供自適應全屏寬度並按等比例縮放、屏幕縱橫比例維持以及寬度外距屬性設置

Downloads

6

Readme

npm version

NPM

react-native-full-ratio-image

擴充 Image 組件,提供以下功能

  • 自適應全屏寬度並按等比例縮放
  • 屏幕縱橫比例維持
  • 寬度外距屬性設置
    • pt 設置
    • 百分比設置

放置 Logo 用 Image 非常適合。以下範例圖片透過 width: '70%' 方式,並隨縱橫比例維持其設置的寬度:

What happened ?

在沒有該擴充 Image 的使用下,一般要能自適應圖片通常會使用寬高百分比,但寬高百分比將會帶來以下問題:

  • 不同手機載具的螢幕解析將會有不同圖片比例效果

  • Android 的 keyboard 將會在彈出鍵盤避免擋住當前的視圖,自動調整視圖的位置,導致百分比設置圖片的寬高將會是不符常規的比例呈現 (寬高被壓縮)

  • 圖片寬高百分比並不會針對手機縱橫使用自動調整比例,需要 reload

Installation

$ npm install react-native-full-ratio-image

Usage

import FullRatioImage from 'react-native-full-ratio-image';

必須提供原始圖片寬高 props 以利該擴充 Image 組件可自動計算等比例圖片縮放。

  • originWidth:number
  • originHeight:number

options props:

  • marginX:number|string

寬度外距 (marginLeft + merginRight = marginX)。可設置 pt 數字或百分比,比如以下範例設置外距為 '30%',讓該圖片以父元件寬度保持 width: '70%'

const LOGO_WIDTH = 3840;
const LOGO_HEIGHT = 906;

class SignInScreen extends Component {
  
  // ...
  
  render() {
    return (
      <View style={[globalStyles.container, globalStyles.center, {backgroundColor: primaryColor}]}>
        <StatusBar barStyle="light-content"/>
        <FullRatioImage
          originalWidth={LOGO_WIDTH}
          originalHeight={LOGO_HEIGHT}
          marginX="30%"
          source={require('../images/ALTA-logo.png')}
          resizeMode="stretch"
          style={[styles.logo]}/>
        {/* ... */}
      </View>
    );
  }
}

License

MIT License. © eden90267