hi guys,
I created a checkout that slides in from the side of the page. It all makes sense if you go to https://www.shinbyeong.com/ scroll down a bit and click on 'pre-order' on the bottom.
So the first time you open the slider it's a bit chucky, then after performing more times it get's better. I guess that's some cache right there.
I added a will-change: transform; on the elements affected. But I didn't see any improvements.
When I use chrome dev tools to record the performance I'm not sure how to analyse it. I don't see large chunks of delayed properties (in ms).
My question:
Can I pre-cache this animation somehow?
What else can I do to improve it?
Here is the code, quite simple is my guess:
.viewport--locked adds overflow hidden on outer element.
.animate-out transitions some transforms on translateX. Nothing special, except that I fire 2 with a delay and try to create a parallax like effect.
const showModal = () => {
viewport.classList.add('viewport--locked')
TweenLite.to(viewportOverlay, .5, {
opacity: 1,
onComplete: () => {
checkoutContainer.classList.add('animate-out')
TweenLite.to(checkout, .5, {
xPercent: -100,
ease: Power4.easeOut
})
}
})
}
const closeModal = () => {
checkoutContainer.classList.remove('animate-out')
TweenLite.to(checkout, .45, {
xPercent: 100,
ease: Power4.easeIn,
onComplete: () => {
TweenLite.to(viewportOverlay, .25, {
opacity: 0,
onComplete: () => viewport.classList.remove('viewport--locked')
})
}
})
}
buyButton.addEventListener('click', () => showModal())
checkoutClose.addEventListener('click', () => closeModal())