Skip to content

Commit

Permalink
Fixes #1359: TOC animations optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarto committed Dec 19, 2016
1 parent 820be28 commit a34fb71
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions web/client/components/TOC/Node.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ var Node = React.createClass({
className: React.PropTypes.string,
type: React.PropTypes.string,
onSort: React.PropTypes.func,
isDraggable: React.PropTypes.bool
isDraggable: React.PropTypes.bool,
animateCollapse: React.PropTypes.bool
},
mixins: [SortableMixin],
getDefaultProps() {
Expand All @@ -49,7 +50,8 @@ var Node = React.createClass({
styler: () => {},
className: "",
type: 'node',
onSort: null
onSort: null,
animateCollapse: true
};
},
renderChildren(filter = () => true) {
Expand All @@ -66,9 +68,13 @@ var Node = React.createClass({
let expanded = (this.props.node.expanded !== undefined) ? this.props.node.expanded : true;
let prefix = this.props.type;
const nodeStyle = assign({}, this.props.style, this.props.styler(this.props.node));
let collapsible = expanded ? this.renderChildren((child) => child && child.props.position === 'collapsible') : [];
if (this.props.animateCollapse) {
collapsible = <ReactCSSTransitionGroup transitionName="TOC-Node" transitionEnterTimeout={250} transitionLeaveTimeout={250}>{collapsible}</ReactCSSTransitionGroup>;
}
let content = (<div key={this.props.node.name} className={(expanded ? prefix + "-expanded" : prefix + "-collapsed") + " " + this.props.className} style={nodeStyle} >
{this.renderChildren((child) => child && child.props.position !== 'collapsible')}
<ReactCSSTransitionGroup transitionName="TOC-Node" transitionEnterTimeout={250} transitionLeaveTimeout={250}>{expanded ? this.renderChildren((child) => child && child.props.position === 'collapsible') : []}</ReactCSSTransitionGroup>
{collapsible}
</div>);
return this.props.isDraggable ? this.renderWithSortable(content) : content;
}
Expand Down

0 comments on commit a34fb71

Please sign in to comment.