Automatically scroll to current Card in Narrative

This commit is contained in:
Franc Camps-Febrer
2019-02-01 14:07:00 -05:00
parent 4af0c9c2ef
commit 3ea3de84b2
2 changed files with 66 additions and 8 deletions

View File

@@ -161,10 +161,12 @@ class Card extends React.Component {
render () {
const { isSelected, idx } = this.props
return (
<li
className={`event-card ${isSelected ? 'selected' : ''}`}
id={`event-card-${idx}`}
ref={this.props.innerRef}
>
{this.renderMain()}
{this.state.isOpen ? this.renderExtra() : null}
@@ -174,4 +176,6 @@ class Card extends React.Component {
}
}
export default Card
// The ref to each card will be used in CardStack for programmatic scrolling
export default React.forwardRef((props, ref) => <Card innerRef={ref} {...props}/>);