Skip to content

Commit 138f389

Browse files
committed
loadingImageComponent prop is added for more customization
1 parent ed74575 commit 138f389

3 files changed

Lines changed: 38 additions & 13 deletions

File tree

README.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</td>
2121
</tr>
2222
<tr>
23-
<td align="center">
23+
<td align="center">
2424
<img alt="React Native Progressive Fast Image"
2525
src="assets/Screenshots/React-Native-Progressive-Fast-Image.gif" />
2626
</td>
@@ -70,12 +70,30 @@ It accepts every `Image` and `FastImage` props. You can use it like you used to.
7070

7171
useNativeDriver?: boolean;
7272

73-
| Property | Type | Default | Description |
74-
| --------------- | :-----------------: | :-------: | ------------------------------------- |
75-
| source | Source | undefined | set the main source of the image |
76-
| thumbnailSource | ImageSourcePropType | undefined | set the thumbnail source of the image |
77-
| loadingSource | ImageSourcePropType | undefined | set the error source of the image |
78-
| errorSource | ImageSourcePropType | undefined | set the loading source of the image |
73+
| Property | Type | Default | Description |
74+
| --------------------- | :-----------------: | :-------: | ------------------------------------- |
75+
| source | Source | undefined | set the main source of the image |
76+
| thumbnailSource | ImageSourcePropType | undefined | set the thumbnail source of the image |
77+
| loadingSource | ImageSourcePropType | undefined | set the error source of the image |
78+
| errorSource | ImageSourcePropType | undefined | set the loading source of the image |
79+
| loadingImageComponent | Component | default | WARNING: Read the below! |
80+
81+
### `loadingImageComponent` Usage
82+
83+
If you want to set your own component for the loading image, you should set this **style** for the top of the component
84+
85+
```javascript
86+
{
87+
top: 0,
88+
left: 0,
89+
right: 0,
90+
bottom: 0,
91+
position: "absolute",
92+
alignItems: "center",
93+
alignSelf: "center",
94+
justifyContent: "center",
95+
}
96+
```
7997

8098
## Customization Props
8199

@@ -98,10 +116,10 @@ useNativeDriver?: boolean;
98116

99117
**Fixes** FastImage's `source null` bug-fix.
100118

101-
- https://github.com/DylanVann/react-native-fast-image/issues/623
102-
- https://github.com/DylanVann/react-native-fast-image/issues/27
103-
- https://github.com/DylanVann/react-native-fast-image/issues/484
104-
- https://github.com/DylanVann/react-native-fast-image/issues/96
119+
- <https://github.com/DylanVann/react-native-fast-image/issues/623>
120+
- <https://github.com/DylanVann/react-native-fast-image/issues/27>
121+
- <https://github.com/DylanVann/react-native-fast-image/issues/484>
122+
- <https://github.com/DylanVann/react-native-fast-image/issues/96>
105123

106124
## Author
107125

@@ -110,3 +128,7 @@ FreakyCoder, kurayogun@gmail.com
110128
## License
111129

112130
React Native Progressive Fast Image is available under the MIT license. See the LICENSE file for more info.
131+
132+
```
133+
134+
```

lib/ProgressiveFastImage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export type CustomFastImageStyleProps =
2424
| StyleProp<FastImageStyle>
2525
| Array<StyleProp<FastImageStyle>>;
2626

27+
2728
interface IProps {
29+
loadingImageComponent?: React.ReactNode;
2830
source: Source;
2931
errorSource?: Source;
3032
loadingSource?: ImageSourcePropType;
@@ -116,13 +118,14 @@ class ProgressiveImage extends React.Component<IProps, IState> {
116118
source,
117119
loadingSource,
118120
thumbnailSource,
121+
loadingImageComponent,
119122
loadingImageStyle = this.props.style,
120123
...props
121124
} = this.props;
122125

123126
return (
124127
<View style={styles.container}>
125-
{loadingSource && !this.state.imageLoaded && (
128+
{loadingImageComponent || loadingSource && !this.state.imageLoaded && (
126129
<View style={[styles.loadingImageStyle, style]}>
127130
<AnimatedFastImage
128131
resizeMode="contain"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@freakycoder/react-native-progressive-fast-image",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "Customizable progressive image for React Native with FastImage",
55
"main": "./build/dist/ProgressiveFastImage.js",
66
"repository": "git@github.com:WrathChaos/react-native-progressive-fast-image.git",

0 commit comments

Comments
 (0)