Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ht5 #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Ht5 #21

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
animate adding new persons
  • Loading branch information
viprogramm committed Jul 18, 2018
commit 3e21184c78fdff918f351f06df1ee502be8d634b
50 changes: 40 additions & 10 deletions admin/src/components/people/people-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { Component } from 'react'
import { connect } from 'react-redux'
import { peopleSelector, fetchAllPeople } from '../../ducks/people'
import { List } from 'react-virtualized'
import { TransitionMotion, spring } from 'react-motion'

import PersonCard from './person-card'

import 'react-virtualized/styles.css'
Expand All @@ -13,20 +15,48 @@ class PeopleList extends Component {

render() {
return (
<List
rowRenderer={this.rowRenderer}
rowCount={this.props.people.length}
rowHeight={150}
height={400}
width={400}
/>
<TransitionMotion
styles={this.styles}
willEnter={this.willEnter}
willLeave={this.willLeave}
>
{(interpolated) => (
<List
scrollToIndex={interpolated.length - 1}
rowRenderer={this.rowRenderer(interpolated)}
rowCount={interpolated.length}
rowHeight={150}
height={400}
width={400}
/>
)}
</TransitionMotion>
)
}

rowRenderer = ({ style, index, key }) => {
const person = this.props.people[index]
willEnter = () => ({
opacity: 0
})

willLeave = () => ({
opacity: spring(0, { stiffness: 20, damping: 40 })
})

get styles() {
return this.props.people.map((people) => ({
key: people.uid,
style: {
opacity: spring(1, { stiffness: 50, damping: 40 })
},
data: people
}))
}

rowRenderer = (interpolated) => ({ style, index, key }) => {
const rowCtx = interpolated[index]
const person = rowCtx.data
return (
<div style={style} key={key}>
<div style={{ ...style, ...rowCtx.style }} key={key}>
<PersonCard person={person} />
</div>
)
Expand Down