@invisionag/iris-react-accordion
Advanced tools
Comparing version 1.2.1 to 1.2.2
28
index.js
@@ -20,3 +20,3 @@ // @flow | ||
startOpen: boolean, | ||
onToggle?: boolean => any, | ||
onToggle: boolean => any, | ||
headerRenderer?: (open: boolean, heading: Jsx) => Jsx, | ||
@@ -32,2 +32,3 @@ headingOpen?: Jsx, | ||
heading: Jsx, | ||
onToggle: () => any, | ||
}; | ||
@@ -42,2 +43,3 @@ | ||
ref: HTMLElement; | ||
timer: number; | ||
@@ -47,2 +49,3 @@ static defaultProps = { | ||
heading: 'Click to toggle', | ||
onToggle: () => {}, | ||
}; | ||
@@ -60,4 +63,16 @@ | ||
componentWillUnmount() { | ||
clearTimeout(this.timer); | ||
} | ||
unsetTransitioningState = () => { | ||
this.setState(prevState => ({ | ||
...prevState, | ||
transitioning: false, | ||
})); | ||
}; | ||
toggleAccordion = (open: boolean) => { | ||
if (typeof this.props.onToggle === 'function') this.props.onToggle(open); | ||
this.props.onToggle(open); | ||
this.setState(prevState => ({ | ||
@@ -68,8 +83,5 @@ ...prevState, | ||
})); | ||
setTimeout( | ||
() => | ||
this.setState(prevState => ({ | ||
...prevState, | ||
transitioning: false, | ||
})), | ||
this.timer = setTimeout( | ||
this.unsetTransitioningState, | ||
parseInt(open ? animationDuration : 0, 10), | ||
@@ -76,0 +88,0 @@ ); |
{ | ||
"name": "@invisionag/iris-react-accordion", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:ivx/iris.git", |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
267
11185
7
1