Skip to content

Commit

Permalink
Merge pull request #6 from sehranhas/fix-accordion
Browse files Browse the repository at this point in the history
Fix accordion
  • Loading branch information
sehranhas authored Jun 7, 2018
2 parents 63338fe + 3af2aff commit 4d87649
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class Accordion extends Component {
}

toggle = () => {
this.refs.AccordionContent.measure((ox, oy, width, height, px, py) => {
this.setState({
height: new Animated.Value(this.state.expanded ? height : 0),
content_height: new Animated.Value(this.state.expanded ? height : 0),
});
});
this.setState({ expanded: !this.state.expanded });
let initialValue = this.state.expanded ? 0 : this.state.content_height;
let finalValue = this.state.expanded ? this.state.content_height : 0;
Expand All @@ -68,9 +74,7 @@ class Accordion extends Component {

_getContentHeight = () => {
if (this.refs.AccordionContent) {
this.refs.AccordionContent.measure((ox, oy, width, height, px, py) => {
// Sets content height in state

this.refs.AccordionContent.measure((ox, oy, width, height, px, py) => {
this.setState({
height: new Animated.Value(this.state.expanded ? height : 0),
content_height: height
Expand Down

0 comments on commit 4d87649

Please sign in to comment.