hi,
so no one has an idea? how to fix the choppy animation on an iMac 27" (chrome and firefox, safari is supersmooth)?
I have taken a screenshot where you can see that it goes down to 8fps...
the related code snippets
this.el_inner.addEventListener('wheel', e => this.wheel(e), {
passive: false
})
deltaY(e) {
let deltaY = 0
if (e.wheelDelta) {
deltaY = -e.wheelDelta
}
if (e.deltaY) {
deltaY = e.deltaY
}
if (e.deltaMode === 1) {
deltaY *= 40
}
return Math.round(deltaY)
},
wheel(e) {
e.preventDefault()
const scrollTo = this.scrollTo + this.deltaY(e)
this.raf('move', scrollTo)
},
move(scrollTo) {
// remove over and under scrolling
this.scrollTo = Math.max(0, Math.min(scrollTo, this.maxScroll))
if (this.innerTweenID) {
this.innerTweenID.kill()
}
this.innerTweenID = TweenMax.to(this.el_body, 1, {
y: -this.scrollTo,
ease: Power4.easeOut,
overwrite: 5,
force3D: 'auto',
onUpdateParams: ['{self}'],
roundProps: 'y'
})
},
//raf is a mixin
raf(cb, e) {
if (this.rafID) {
window.cancelAnimationFrame(this.rafID)
}
this.rafID = window.requestAnimationFrame(() => this[cb](e))
demo there
code -> https://codesandbox.io/s/1z86xjl6q3 full window -> https://1z86xjl6q3.codesandbox.io/
I also tried to animate a nullObject und set the transform onUpdate, but doesn't solved the problem
this.innerTweenID = TweenMax.to(this.nullYObject, 1.2, {
y: this.scrollTo,
ease: Power4.easeOut,
overwrite: 5,
force3D: 'auto',
onUpdateParams: ['{self}'],
onUpdate: tween => {
const scrollTop = Math.round(tween.target.y)
this.el_body.style.transform =
'translateY(' + -scrollTop + 'px) translateZ(0)'
}
})
gregor