i have a problem with a mouse controller lottie animation.
therefore i created this pen, to fiddle around :)
https://codepen.io/duderion/pen/bGbXNqe
the goal is, that the lottie animation goes from top to bottom of the viewport (minus the top menu), left and right should be cropped (You cant show the whole animation at once, so cropping is a natural behaviour)
I thought (and i still think) that "xMidYMax slice" is the right approach. I think of it as "Maximize the height, and slice left and right"...
i tried to set it in the bodymovin renderer settings
var animData = {
container: document.getElementById("sec"),
renderer: "svg",
prerender: true,
loop: false,
autoplay: false,
offset: 500,
rendererSettings: {
progressiveLoad: false,
preserveAspectRatio: "xMidYMax slice"
},
path:
"https://uberserver.de/uncabka/wp-content/plugins/elementor-cabka/assets/js/animation.json"
};
But no matter what i do, it doesnt change its format if i resize the viewport.
the animation is just within this frame, not full height :(
I hope, someone here has experience with this kind of problems and could give me a hint.
Thanks in advance
Adrian
After putting the code in an easier version to codepen, i found the solution.
it's this code:
//bind the complete function to the data_ready event of bodymovin's animation loader
anim.addEventListener("data_ready", complete);
//set the attribute manually after the svg is loaded.
function complete() {
$('#sec svg').attr('preserveAspectRatio','xMidYMax slice');
}