Footer: Animation depend on the direction.

This commit is contained in:
Yohan Boujon 2024-08-11 21:57:09 +01:00
parent a68ba0aa74
commit 870b6dbdfb

View file

@ -14,17 +14,18 @@
function slideText(event) { function slideText(event) {
const id = event.detail.id; const id = event.detail.id;
const width = window.innerWidth; const width = window.innerWidth/2;
const animTranslate = active > id ? [width, -width] : [-width, width];
anime({ anime({
targets: pageDiv, targets: pageDiv,
translateX: width / 2, translateX: animTranslate[0],
opacity: 0, opacity: 0,
duration: 300, duration: 300,
easing: 'easeInQuad', easing: 'easeInQuad',
complete: function () { complete: function () {
active = id; active = id;
pageDiv.style.transform = `translateX(-${width}px)`; pageDiv.style.transform = `translateX(${animTranslate[1]}px)`;
anime({ anime({
targets: pageDiv, targets: pageDiv,
translateX: 0, translateX: 0,