From 918d5b29ad49bcc94386668ca95347c79bb08970 Mon Sep 17 00:00:00 2001 From: YuriyUlantsev Date: Sun, 2 Jul 2017 19:08:33 +0300 Subject: [PATCH 1/5] added useNativeDriver to Animated timing function --- Pulse.js | 7 ++++--- PulseLoader.js | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Pulse.js b/Pulse.js index e935e1f..30735c6 100644 --- a/Pulse.js +++ b/Pulse.js @@ -6,7 +6,7 @@ const { height, width } = Dimensions.get('window'); export default class Pulse extends React.Component { constructor(props) { super(props); - + this.anim = new Animated.Value(0); } @@ -15,6 +15,7 @@ export default class Pulse extends React.Component { toValue: 1, duration: this.props.interval, easing: Easing.in, + useNativeDriver: true }) .start(); } @@ -50,7 +51,7 @@ export default class Pulse extends React.Component { /> ); - } + } } @@ -65,4 +66,4 @@ const styles = StyleSheet.create({ circle: { borderWidth: 4 * StyleSheet.hairlineWidth, }, -}); \ No newline at end of file +}); diff --git a/PulseLoader.js b/PulseLoader.js index d362815..5e45db5 100644 --- a/PulseLoader.js +++ b/PulseLoader.js @@ -6,7 +6,7 @@ import Pulse from './Pulse'; export default class LocationPulseLoader extends React.Component { constructor(props) { super(props); - + this.state = { circles: [] }; @@ -35,6 +35,7 @@ export default class LocationPulseLoader extends React.Component { toValue: this.props.pressInValue, duration: this.props.pressDuration, easing: this.props.pressInEasing, + useNativeDriver: true }).start(() => clearInterval(this.setInterval)); } @@ -43,6 +44,7 @@ export default class LocationPulseLoader extends React.Component { toValue: 1, duration: this.props.pressDuration, easing: this.props.pressOutEasing, + useNativeDriver: true }).start(this.setCircleInterval.bind(this)); } @@ -85,7 +87,7 @@ export default class LocationPulseLoader extends React.Component { ); - } + } } LocationPulseLoader.propTypes = { @@ -115,4 +117,3 @@ LocationPulseLoader.defaultProps = { backgroundColor: '#ED225B55', getStyle: undefined, }; - From d8d4a4167e09bc4fc8ad1ed369656c78063cde65 Mon Sep 17 00:00:00 2001 From: YuriyUlantsev Date: Sun, 2 Jul 2017 19:16:18 +0300 Subject: [PATCH 2/5] rm useNativeDriver from timing function because not support width style --- Pulse.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Pulse.js b/Pulse.js index 30735c6..117a39d 100644 --- a/Pulse.js +++ b/Pulse.js @@ -14,8 +14,7 @@ export default class Pulse extends React.Component { Animated.timing(this.anim, { toValue: 1, duration: this.props.interval, - easing: Easing.in, - useNativeDriver: true + easing: Easing.in }) .start(); } From 8af87ca0bbd435793ec0a08adc0e2aea71c293fa Mon Sep 17 00:00:00 2001 From: YuriyUlantsev Date: Sun, 2 Jul 2017 19:30:35 +0300 Subject: [PATCH 3/5] added avatarStyle prop to PulseLoader.js --- PulseLoader.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PulseLoader.js b/PulseLoader.js index 5e45db5..dd068ab 100644 --- a/PulseLoader.js +++ b/PulseLoader.js @@ -77,12 +77,12 @@ export default class LocationPulseLoader extends React.Component { > @@ -101,6 +101,7 @@ LocationPulseLoader.propTypes = { borderColor: React.PropTypes.string, backgroundColor: React.PropTypes.string, getStyle: React.PropTypes.func, + avatarStyle: Image.propTypes.style }; LocationPulseLoader.defaultProps = { @@ -116,4 +117,5 @@ LocationPulseLoader.defaultProps = { borderColor: '#D8335B', backgroundColor: '#ED225B55', getStyle: undefined, + avatarStyle: {} }; From 69502ab3611c9a59269591c2249f34434b232c65 Mon Sep 17 00:00:00 2001 From: YuriyUlantsev Date: Sun, 2 Jul 2017 21:56:01 +0300 Subject: [PATCH 4/5] added clearInterval to componentWillUnmount handler --- PulseLoader.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PulseLoader.js b/PulseLoader.js index dd068ab..c7d2464 100644 --- a/PulseLoader.js +++ b/PulseLoader.js @@ -20,6 +20,10 @@ export default class LocationPulseLoader extends React.Component { this.setCircleInterval(); } + componentWillUnmount(){ + clearInterval(this.setInterval); + } + setCircleInterval() { this.setInterval = setInterval(this.addCircle.bind(this), this.props.interval); this.addCircle(); From 538c9beec8364844e60cb6d178663b40dbe6322d Mon Sep 17 00:00:00 2001 From: YuriyUlantsev Date: Fri, 7 Jul 2017 11:09:52 +0300 Subject: [PATCH 5/5] fix source avatar --- PulseLoader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PulseLoader.js b/PulseLoader.js index c7d2464..f9580b4 100644 --- a/PulseLoader.js +++ b/PulseLoader.js @@ -80,7 +80,7 @@ export default class LocationPulseLoader extends React.Component { }} >