Skip to content

Instantly share code, notes, and snippets.

@tiagoengel
Created June 8, 2017 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiagoengel/783a31090646f81254f2401e6c6ce837 to your computer and use it in GitHub Desktop.
Save tiagoengel/783a31090646f81254f2401e6c6ce837 to your computer and use it in GitHub Desktop.
toggle(e) {
e.preventDefault();
let wrapperHeight = this.refs.transitionWrapper.clientHeight;
if (this.state.expanded) {
this.setState({ expanded: false, submenuHeight: 0 }));
} else {
this.setState({
expanded: true,
submenuHeight: wrapperHeight
});
}
}
<div className="submenu" ref="submenu" style={{ height: submenuHeight }}>
<div ref="transitionWrapper">
{childrens}
</div>
</div>
.submenu {
@include transition(height, 0.3s, ease-in);
height: 0;
overflow: hidden;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment