1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 09:13:19 +01:00

remove availability scroll stuff

This commit is contained in:
Matthias Kretschmann 2018-06-12 10:39:03 +02:00
parent 2f13a07652
commit 542dc58244
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -8,52 +8,6 @@ class Availability extends PureComponent {
super(props)
}
componentDidMount() {
if (this.props.meta.availability.status === true) {
let supportsPassive = false
try {
const opts = Object.defineProperty({}, 'passive', {
get: function() {
supportsPassive = true
}
})
window.addEventListener('test', null, opts)
} catch (e) {
return e
}
window.addEventListener(
'scroll',
this.handleScroll,
supportsPassive ? { passive: true } : false
)
}
}
componentWillUnmount() {
window.removeEventListener('scroll', this.handleScroll)
}
handleScroll = () => {
let timeout
const footer = document.getElementsByClassName('footer')[0]
const availability = document.getElementsByClassName('availability')[0]
if (!timeout) {
timeout = setTimeout(function() {
timeout = null
if (footer.getBoundingClientRect().top <= window.innerHeight) {
availability.style.opacity = 0
window.removeEventListener('scroll', this.handleScroll)
} else {
availability.style.opacity = 1
}
}, 300)
}
}
render() {
const { availability } = this.props.meta
const { status, available, unavailable } = availability