Skip to content

Commit

Permalink
feat: aad scale property to control cross fade icon animation time (c…
Browse files Browse the repository at this point in the history
  • Loading branch information
Taym95 authored and ferrannp committed May 23, 2019
1 parent b852293 commit 4d47b4e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/components/CrossFadeIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Animated, StyleSheet, View } from 'react-native';
import { polyfill } from 'react-lifecycles-compat';
import Icon, { isValidIcon, isEqualIcon } from './Icon';
import type { IconSource } from './Icon';
import { withTheme } from '../core/theming';
import type { Theme } from '../types';

type Props = {|
/**
Expand All @@ -19,6 +21,10 @@ type Props = {|
* Size of the icon.
*/
size: number,
/**
* @optional
*/
theme: Theme,
|};

type State = {
Expand Down Expand Up @@ -47,6 +53,11 @@ class CrossFadeIcon extends React.Component<Props, State> {

componentDidUpdate(prevProps: Props, prevState: State) {
const { previousIcon } = this.state;
const {
theme: {
animation: { scale },
},
} = this.props;

if (
!isValidIcon(previousIcon) ||
Expand All @@ -58,7 +69,7 @@ class CrossFadeIcon extends React.Component<Props, State> {
this.state.fade.setValue(1);

Animated.timing(this.state.fade, {
duration: 200,
duration: scale * 200,
toValue: 0,
}).start();
}
Expand Down Expand Up @@ -126,7 +137,7 @@ class CrossFadeIcon extends React.Component<Props, State> {

polyfill(CrossFadeIcon);

export default CrossFadeIcon;
export default withTheme(CrossFadeIcon);

const styles = StyleSheet.create({
content: {
Expand Down

0 comments on commit 4d47b4e

Please sign in to comment.