HI all! I hope someone can help me solve this pickle
so I am trying to create a CMS gallery with lottie animations that I have created. I have a CMS collection that with fields that provide lottie URL (from lottiefiles) and then other variables that I can set on a per CMS Item basis (i.e. loop, controls, autoplay, hover, etc…) and each of the CMS items has a HTML Embed that contains the following code:
<lottie-player
loop = "true"
src="https://assets1.lottiefiles.com/packages/lf20_04k3nw3k.json"
hover="true"
background="#383838"
mode="normal"
renderer = "svg"
rendererSettings: {
filterSize: {
width: '200%',
height: '200%',
x: '-50%',
y: '-50%',
}
></lottie-player>
and the various variables are set in the collection item.
There is an additional embed that is outside of the collection which adds the JS script source. So my problem is the following, I have another part of the script that I need to include, that will set the start frame for each of the animation (some of my animations are loops which start/end with an empty frame so I would like to set a static hold frame for each animation so that before any hover events they will show something and not sit empty:
<script>
const player = document.querySelector("lottie-player");
player.getLottie().goToAndStop(20, true);
player.addEventListener(
"mouseover",
function (event) {
player.stop();
player.setLooping(true);
player.play();
},
false
);
player.addEventListener(
"mouseout",
function (event) {
player.getLottie().goToAndStop(20, true);
player.setLooping(false);
},
false
);
</script>
where I need the frame numbers (20) to be dynamically set with the figure that I will include in each CMS item - BUT if I include this script in the HTML embed it doesn’t work since it calls for the player multiple times (for each CMS item on the page) and I not sure how to get around this…
I hope I have explained my problem with sufficient clarity - any insight and/or suggestions will be greatly appreciated!
Here is my site Read-Only: (https://preview.webflow.com/preview/mograph?utm_medium=preview_link&utm_source=designer&utm_content=mograph&preview=01aafb7cec108e1b262b961686b3402c&pageId=609e92c965fead4ade4a9138&mode=preview)