Skip to content

Commit 9587256

Browse files
author
Benoît Delmaire
authored
Merge pull request #588 from DanielMarkiel/custom-animated-image
Custom animated image component
2 parents f645204 + 21f1d31 commit 9587256

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

doc/PARALLAX_IMAGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Prop | Description | Type | Default
1414
`parallaxFactor` | Speed of the parallax effect. Be aware that the bigger the value, the more image will appear "zoomed in". | Number | `0.3`
1515
`showSpinner` | Whether to display a spinner while image is loading or not | Boolean | `true`
1616
`spinnerColor` | Color of the spinner | String | 'rgba(0, 0, 0, 0.4)'
17+
`AnimatedImageComponent` | Custom animated image component | Function Object | `Animated.Image`
1718

1819
All [`<Image />` props](https://facebook.github.io/react-native/docs/image.html#props) are also inherited, **particularly `source` which is required**.
1920

src/parallaximage/ParallaxImage.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,20 @@ export default class ParallaxImage extends Component {
2424
fadeDuration: PropTypes.number,
2525
parallaxFactor: PropTypes.number,
2626
showSpinner: PropTypes.bool,
27-
spinnerColor: PropTypes.string
27+
spinnerColor: PropTypes.string,
28+
AnimatedImageComponent: PropTypes.oneOfType([
29+
PropTypes.func,
30+
PropTypes.object
31+
])
2832
};
2933

3034
static defaultProps = {
3135
containerStyle: {},
3236
fadeDuration: 500,
3337
parallaxFactor: 0.3,
3438
showSpinner: true,
35-
spinnerColor: 'rgba(0, 0, 0, 0.4)'
39+
spinnerColor: 'rgba(0, 0, 0, 0.4)',
40+
AnimatedImageComponent: Animated.Image
3641
}
3742

3843
constructor (props) {
@@ -146,6 +151,7 @@ export default class ParallaxImage extends Component {
146151
sliderHeight,
147152
parallaxFactor,
148153
style,
154+
AnimatedImageComponent,
149155
...other
150156
} = this.props;
151157

@@ -174,7 +180,7 @@ export default class ParallaxImage extends Component {
174180
};
175181

176182
return (
177-
<Animated.Image
183+
<AnimatedImageComponent
178184
{...other}
179185
style={[styles.image, style, requiredStyles, dynamicStyles]}
180186
onLoad={this._onLoad}

0 commit comments

Comments
 (0)