Skip to content

Invoke onLoad prop on onLoad #1033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/animatedImage/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// TODO: consider unify this component functionality with our Image component
import _ from 'lodash';
import PropTypes from 'prop-types';
import React from 'react';
import {Animated, View, StyleSheet} from 'react-native';
Expand Down Expand Up @@ -43,11 +44,12 @@ class AnimatedImage extends BaseComponent {
this.state = {opacity: new Animated.Value(0), isLoading: true};
}

onLoad = () => {
onLoad = (...args) => {
this.setState({isLoading: false}, () => {
const animationParams = {toValue: 1, duration: this.props.animationDuration, useNativeDriver: true};
Animated.timing(this.state.opacity, animationParams).start();
});
_.invoke(this.props, 'onLoad', ...args);
};

render() {
Expand All @@ -58,7 +60,7 @@ class AnimatedImage extends BaseComponent {
{...others}
style={[{opacity: this.state.opacity}, style]}
source={source}
onLoad={() => this.onLoad()}
onLoad={this.onLoad}
testID={testID}
/>
{this.state.isLoading && loader && (
Expand Down