From 2129eb6b43f67ef81a926e1a7597affd74dbf0da Mon Sep 17 00:00:00 2001 From: Juan David Nicholls Cardona Date: Wed, 11 Mar 2020 09:27:31 -0500 Subject: [PATCH 1/2] Added style prop to TranslateYAndOpacity component and documentation for TranslateY and TranslateYAndOpacity components --- src/TranslateY/README.md | 13 +++++++++++++ src/{TranslateY.js => TranslateY/index.js} | 4 ++++ src/TranslateYAndOpacity/README.md | 12 ++++++++++++ .../index.js} | 16 +++++++++++----- 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 src/TranslateY/README.md rename src/{TranslateY.js => TranslateY/index.js} (90%) create mode 100644 src/TranslateYAndOpacity/README.md rename src/{TranslateYAndOpacity.js => TranslateYAndOpacity/index.js} (92%) diff --git a/src/TranslateY/README.md b/src/TranslateY/README.md new file mode 100644 index 0000000..1159447 --- /dev/null +++ b/src/TranslateY/README.md @@ -0,0 +1,13 @@ +# TranslateYAndOpacity + +## Properties + +| Property | Description | Default | +| ----------- | ----------- | ------- | +| `type` | Sets the animation type. | `timing` | +| `value` | Sets the current Y position. | `null` | +| `duration` | The number of milliseconds each iteration of the animation takes to complete. | `500` | +| `delay` | The number of milliseconds to delay the start of the animation. | `0` | +| `initialValue` | Sets the initial Y position from where the element will start the animation up to the current value. | `null` | +| `animateOnDidMount` | Start the animation when the component is mounted. | `false` | +| `useNativeDriver` | Uses the native driver when true. | `false` | \ No newline at end of file diff --git a/src/TranslateY.js b/src/TranslateY/index.js similarity index 90% rename from src/TranslateY.js rename to src/TranslateY/index.js index 7e27ced..0e3f831 100644 --- a/src/TranslateY.js +++ b/src/TranslateY/index.js @@ -5,6 +5,8 @@ import PropTypes from 'prop-types'; const propTypes = { type: PropTypes.string, value: PropTypes.number, + duration: PropTypes.number, // eslint-disable-line react/no-unused-prop-types + delay: PropTypes.number, // eslint-disable-line react/no-unused-prop-types initialValue: PropTypes.number, startOnDidMount: PropTypes.bool, useNativeDriver: PropTypes.bool, @@ -12,6 +14,8 @@ const propTypes = { const defaultProps = { type: 'timing', value: 0, + duration: 500, + delay: 0, initialValue: null, startOnDidMount: false, useNativeDriver: true, diff --git a/src/TranslateYAndOpacity/README.md b/src/TranslateYAndOpacity/README.md new file mode 100644 index 0000000..d444540 --- /dev/null +++ b/src/TranslateYAndOpacity/README.md @@ -0,0 +1,12 @@ +# TranslateYAndOpacity + +## Properties + +| Property | Description | Default | +| ----------- | ----------- | ------- | +| `opacityMin` | Sets the minimum opacity. | `0` | +| `translateYMin` | Sets the initial Y position from where the element will start the animation up to 0. | `-4` | +| `duration` | The number of milliseconds each iteration of the animation takes to complete. | `500` | +| `delay` | The number of milliseconds to delay the start of the animation. | `0` | +| `animateOnDidMount` | Start the animation when the component is mounted. | `false` | +| `useNativeDriver` | Uses the native driver when true. | `true` | \ No newline at end of file diff --git a/src/TranslateYAndOpacity.js b/src/TranslateYAndOpacity/index.js similarity index 92% rename from src/TranslateYAndOpacity.js rename to src/TranslateYAndOpacity/index.js index fdcdb18..e729fc2 100644 --- a/src/TranslateYAndOpacity.js +++ b/src/TranslateYAndOpacity/index.js @@ -6,17 +6,17 @@ const propTypes = { opacityMin: PropTypes.number, translateYMin: PropTypes.number, duration: PropTypes.number, // eslint-disable-line react/no-unused-prop-types - animateOnDidMount: PropTypes.bool, delay: PropTypes.number, // eslint-disable-line react/no-unused-prop-types + animateOnDidMount: PropTypes.bool, useNativeDriver: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types }; const defaultProps = { opacityMin: 0, translateYMin: -4, duration: 500, - animateOnDidMount: false, delay: 0, - useNativeDriver: false, + animateOnDidMount: false, + useNativeDriver: true, }; class TranslateYAndOpacity extends PureComponent { @@ -88,7 +88,7 @@ class TranslateYAndOpacity extends PureComponent { }); } render() { - const { children } = this.props; + const { style, children } = this.props; const { opacityValue, translateYValue } = this.state; const animatedStyle = { @@ -96,7 +96,13 @@ class TranslateYAndOpacity extends PureComponent { transform: [{ translateY: translateYValue }], }; - return {children}; + return ( + + {children} + + ); } } From 7c812b4d1dd2521068d07dbe22fa028e1c32cb93 Mon Sep 17 00:00:00 2001 From: Juan David Nicholls Cardona Date: Wed, 11 Mar 2020 09:37:49 -0500 Subject: [PATCH 2/2] Fix linter issue --- src/TranslateYAndOpacity/index.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/TranslateYAndOpacity/index.js b/src/TranslateYAndOpacity/index.js index e729fc2..9109c9b 100644 --- a/src/TranslateYAndOpacity/index.js +++ b/src/TranslateYAndOpacity/index.js @@ -97,11 +97,7 @@ class TranslateYAndOpacity extends PureComponent { }; return ( - - {children} - + {children} ); } }