Answer the question
In order to leave comments, you need to log in
Anime.js How to animate the transition of an element to the center of the page, depending on the resolution?
There is an element that, when loading the page, should smoothly move from the left side of the screen to the center, depending on the resolution of the device. The parameter translateX: 0,
does not accept percentages. It is necessary that this be implemented on the Anime.js plugin
https://codepen.io/WafelT/pen/oNZdKOY
Answer the question
In order to leave comments, you need to log in
const logoEl = document.querySelector("#logo");
const logoRect = logoEl.getBoundingClientRect();
let logoAnim = anime({
targets: logoEl,
duration: 1500,
translateX: (window.innerWidth - logoRect.width) / 2 - logoRect.x,
translateY: (window.innerHeight - logoRect.height) / 2 - logoRect.y,
easing: "easeInOutExpo"
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question