2.2.1 • Published 5 years ago

rax-picture v2.2.1

Weekly downloads
22
License
BSD-3-Clause
Repository
github
Last release
5 years ago

Picture

npm

Complex image component

Install

$ npm install rax-picture --save

Import

import Picture from 'rax-picture';

Props

nametypedefaultdescribe
sourceobject{uri: ''}picture source(need)
styleobjectmust set style.width ,style.height ,(need)
resizeModestringstretchHow to adjust the size of the picture when the picture size is out of proportion
forceUpdatebooleanfalsePicture is a PureComponent ,It will render when porps.source.uri has change (in shouldComponentUpdate), If you want to ignore shouldComponentUpdate,you need forceUpdate={true}
widthnumberpicture width (px)
heightnumberpicture height (px)
lazyloadbooleanfalse(for web)picture lazyload,useing://g.alicdn.com/kg/appear/0.2.2/appear.min.js
autoPixelRatiobooleantrue(for web)high resolution
placeholderstring(for web)background image for lazyload
autoRemoveSchemebooleantrue(for web) Automatic deletion protocol header

resizeMode value:

  • cover: Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).
  • contain: Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).
  • stretch: Scale width and height independently, This may change the aspect ratio of the src.

(must set style.width && style.height)

Example

import {createElement, Component, render} from 'rax';
import ScrollView from 'rax-scrollview';
import 'rax-components'; // hack for rax-picture@0.2.5
import Picture from 'rax-picture';

class Demo extends Component {
  render() {
    return <ScrollView ref='scroll'>
       <Picture
         source={{
           uri: '//gw.alicdn.com/tfscom/tuitui/TB2jLF1lXXXXXc7XXXXXXXXXXXX_!!0-dgshop.jpg',
         }}
         style={{
           width: 375,
           height: 252
         }}
         lazyload={true}
         resizeMode="cover"
       />
    </ScrollView>;
  }
}
render(<Demo />);

Local image example

useing image-source-loader in webpack.config.js

import {createElement, Component, render} from 'rax';
import Image from 'rax-image';

class App extends Component {
  render() {
    return (
      <Image source={require('./path/to/your/image.png')}
        resizeMode="cover"
      />
    );
  }
}

render(<App />);
2.3.0-5

5 years ago

2.3.0-4

5 years ago

2.3.0-6

5 years ago

2.3.0-1

5 years ago

2.3.0-3

5 years ago

2.3.0-0

5 years ago

2.2.2-beta.3

5 years ago

2.2.2-beta.2

5 years ago

2.2.2-beta.1

5 years ago

2.2.2-beta.0

5 years ago

2.2.2-2

5 years ago

2.2.2-1

5 years ago

2.2.2-0

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.2.0-0

5 years ago

2.1.0

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.6-0

6 years ago

1.1.6-beta.1

6 years ago

1.1.5

6 years ago

1.1.5-beta.3

6 years ago

1.1.5-beta.2

6 years ago

1.1.5-beta.1

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.3-0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0-3

6 years ago

1.1.0-2

6 years ago

1.1.0

6 years ago

1.1.0-1

6 years ago

1.1.0-0

6 years ago

1.0.4-0

6 years ago

1.0.3

6 years ago

1.0.3-beta.2

6 years ago

1.0.3-0

6 years ago

1.0.2

6 years ago

1.0.3-beta.1

6 years ago

1.0.1

6 years ago

1.0.1-beta.2

6 years ago

1.0.1-beta.1

6 years ago

1.0.1-beta.0

6 years ago

1.0.0

6 years ago

1.0.0-beta.1

6 years ago

1.0.0-beta.0

6 years ago

0.7.3

6 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.6-1

7 years ago

0.6.6

7 years ago

0.6.5

7 years ago

0.6.4

7 years ago

0.6.3

7 years ago

0.6.2

7 years ago

0.6.0

7 years ago

0.5.4

7 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

8 years ago

0.4.20

8 years ago

0.4.19

8 years ago

0.4.18

8 years ago

0.4.17

8 years ago

0.4.16

8 years ago

0.4.15

8 years ago

0.5.0-beta

8 years ago

0.4.14

8 years ago

0.4.13

8 years ago

0.4.12

8 years ago

0.4.11

8 years ago

0.4.10

8 years ago

0.4.9

8 years ago

0.4.8

8 years ago

0.4.7

8 years ago

0.4.6

8 years ago

0.4.5

8 years ago

0.4.4

8 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.8

8 years ago

0.3.7

8 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.11

8 years ago

0.2.10

8 years ago

0.2.9

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago