Skip to content

Commit

Permalink
Merge pull request #2706 from aljourda/master
Browse files Browse the repository at this point in the history
Fixed animation hangup / Using the native driver
  • Loading branch information
sankhadeeproy007 authored Jul 4, 2019
2 parents b4047bf + 9d4dc33 commit 3939624
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 46 deletions.
2 changes: 1 addition & 1 deletion dist/src/basic/Accordion.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/src/basic/Accordion.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/src/basic/Fab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/src/basic/Fab.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/src/basic/Item.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/src/basic/Item.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/src/basic/SwipeRow.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/src/basic/SwipeRow.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/basic/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class AccordionSubItem extends React.Component {
componentDidMount() {
Animated.timing(this.state.fadeAnim, {
toValue: 1,
duration: 500
duration: 500,
useNativeDriver: true
}).start();
}
render() {
Expand Down
48 changes: 32 additions & 16 deletions src/basic/Fab.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,20 +308,24 @@ class Fab extends Component {
upAnimate() {
if (!this.props.active) {
Animated.spring(this.containerHeight, {
toValue: this.state.buttons * 51.3 + 56
toValue: this.state.buttons * 51.3 + 56,
useNativeDriver: true
}).start();
Animated.spring(this.buttonScale, {
toValue: 1
toValue: 1,
useNativeDriver: true
}).start();
} else {
this.setState({
active: false
});
Animated.spring(this.containerHeight, {
toValue: 56
toValue: 56,
useNativeDriver: true
}).start();
Animated.spring(this.buttonScale, {
toValue: 0
toValue: 0,
useNativeDriver: true
}).start();
}
}
Expand All @@ -345,62 +349,74 @@ class Fab extends Component {
leftAnimate() {
if (!this.props.active) {
Animated.spring(this.containerWidth, {
toValue: this.state.buttons * 51.3 + 56
toValue: this.state.buttons * 51.3 + 56,
useNativeDriver: true
}).start();
Animated.spring(this.buttonScale, {
toValue: 1
toValue: 1,
useNativeDriver: true
}).start();
} else {
this.setState({
active: false
});
Animated.spring(this.containerHeight, {
toValue: 56
toValue: 56,
useNativeDriver: true
}).start();
Animated.spring(this.buttonScale, {
toValue: 0
toValue: 0,
useNativeDriver: true
}).start();
}
}

rightAnimate() {
if (!this.props.active) {
Animated.spring(this.containerWidth, {
toValue: this.state.buttons * 51.3 + 56
toValue: this.state.buttons * 51.3 + 56,
useNativeDriver: true
}).start();
Animated.spring(this.buttonScale, {
toValue: 1
toValue: 1,
useNativeDriver: true
}).start();
} else {
this.setState({
active: false
});
Animated.spring(this.containerHeight, {
toValue: 56
toValue: 56,
useNativeDriver: true
}).start();
Animated.spring(this.buttonScale, {
toValue: 0
toValue: 0,
useNativeDriver: true
}).start();
}
}

downAnimate() {
if (!this.props.active) {
Animated.spring(this.containerHeight, {
toValue: 56
toValue: 56,
useNativeDriver: true
}).start();
Animated.spring(this.buttonScale, {
toValue: 1
toValue: 1,
useNativeDriver: true
}).start();
} else {
this.setState({
active: false
});
Animated.spring(this.containerHeight, {
toValue: 56
toValue: 56,
useNativeDriver: true
}).start();
Animated.spring(this.buttonScale, {
toValue: 0
toValue: 0,
useNativeDriver: true
}).start();
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/basic/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,26 @@ class Item extends Component {
floatBack() {
Animated.timing(this.state.topAnim, {
toValue: 18,
duration: 150
duration: 150,
useNativeDriver: true
}).start();
Animated.timing(this.state.opacAnim, {
toValue: 1,
duration: 150
duration: 150,
useNativeDriver: true
}).start();
}

floatUp(e) {
Animated.timing(this.state.topAnim, {
toValue: e || -22,
duration: 150
duration: 150,
useNativeDriver: true
}).start();
Animated.timing(this.state.opacAnim, {
toValue: 0.7,
duration: 150
duration: 150,
useNativeDriver: true
}).start();
}

Expand Down
33 changes: 16 additions & 17 deletions src/basic/SwipeRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ class SwipeRow extends Component {
}

getPreviewAnimation(toValue, delay) {
return Animated.timing(this._translateX, {
duration: this.props.previewDuration,
toValue,
delay
});
return Animated.timing(this._translateX, { duration: this.props.previewDuration, toValue, delay, useNativeDriver: true});
}

onContentLayout(e) {
Expand Down Expand Up @@ -188,18 +184,21 @@ class SwipeRow extends Component {
this.manuallySwipeRow(this.props.rightOpenValue);
}

manuallySwipeRow(toValue) {
Animated.spring(this._translateX, {
toValue,
friction: this.props.friction,
tension: this.props.tension
}).start(_ => {
if (toValue === 0) {
this.props.onRowDidClose && this.props.onRowDidClose();
} else {
this.props.onRowDidOpen && this.props.onRowDidOpen();
}
});

manuallySwipeRow(toValue) {
Animated.spring(this._translateX, {
toValue,
friction: this.props.friction,
tension: this.props.tension,
useNativeDriver: true
}).start(_ => {
if (toValue === 0) {
this.props.onRowDidClose && this.props.onRowDidClose();
} else {
this.props.onRowDidOpen && this.props.onRowDidOpen();
}
});


if (toValue === 0) {
this.props.onRowClose && this.props.onRowClose();
Expand Down

0 comments on commit 3939624

Please sign in to comment.