how to Lottie / json animations?
-
Hello I have been making vector animations using Cavalry App and would like to export them as a Lottie / JSON file and upload them as looping background video animations to page rows.
Does anyone know how to do this?Thanks
-
Haven't tested out but you can try to:
- Include the Lottie library in your project via CDN Link
<script src="lottie.min.js"></script>
-
Give the row you would like to assign the animation to a class oder id (e.g. #animation-container)
<script> window.laytheme.on("newpageshown", function(){ const animationContainer = document.getElementById('animation-container'); // replace with your div ID const animationData = { container: animationContainer, renderer: 'svg', loop: true, autoplay: true, path: 'your-animation.json' // replace with the path to your Lottie JSON file }; const animation = lottie.loadAnimation(animationData); }); </script>
- Add this to your Custom CSS
#animation-container { background-image: url("data:image/svg+xml;utf8," + encodeURIComponent(animationData.container.innerHTML)); }
to make the created SVG your background-image
Good luck ;)
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it
Forgot your key, lost your files, need a previous Lay Theme or Addon version?
Go to www.laykeymanager.com