1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-23 01:29:41 +01:00

project nav fixes

This commit is contained in:
Matthias Kretschmann 2018-07-10 17:06:38 +02:00
parent 5cab4011b9
commit eb0ed97293
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -46,7 +46,7 @@ class ProjectNav extends Component {
const currentWidth = current.clientWidth const currentWidth = current.clientWidth
const finalPosition = currentLeft - window.innerWidth / 2 + currentWidth / 2 const finalPosition = currentLeft - window.innerWidth / 2 + currentWidth / 2
this.scrollContainer.scrollLeft = finalPosition this.scrollContainer.scrollLeft += finalPosition
} }
render() { render() {
@ -80,9 +80,7 @@ class ProjectNav extends Component {
<FullWidth> <FullWidth>
<nav <nav
className={styles.projectNav} className={styles.projectNav}
ref={node => { ref={node => (this.scrollContainer = node)}
this.scrollContainer = node
}}
> >
{projects.map(({ node }) => { {projects.map(({ node }) => {
const current = node.slug === slug const current = node.slug === slug
@ -91,9 +89,7 @@ class ProjectNav extends Component {
<div <div
className={styles.item} className={styles.item}
key={node.slug} key={node.slug}
ref={node => { ref={node => current && (this.currentItem = node)}
if (current) this.currentItem = node
}}
> >
<ProjectLink node={node} /> <ProjectLink node={node} />
</div> </div>