I'm getting the error this.updateCSSAnimation is not a function, but i'm unsure why as I have bound it in my constructor. I have tried this.updateCSSAnimation with and without parenthesis but neither work.
import React from 'react'
class ScrollBG extends React.Component {
constructor(props) {
super(props)
this.updateCSSAnimation = this.updateCSSAnimation.bind(this)
}
componentDidMount () {
document.addEventListener('scroll', this.handleScroll)
}
componentWillUnmount () {
document.removeEventListener('scroll', this.handleScroll)
}
handleScroll () {
this.scroll = window.ScrollY
this.globe = document.querySelector('.globe')
this.map = document.querySelector('.map')
this.updateCSSAnimation()
}
updateCSSAnimation () {
const scroll = this.scroll
this.globe.style.bottom = 0 + 200 * (scroll / 250) + 'px'
this.map.style.width = 68 + (scroll / 50) + 'rem'
}
render () {
return (
<section className='map'>
<div className='globe'>
stuff
</div>
</section>
)
}
}
export default ScrollBG