Home > Software design >  How to watch any changes in object animation svg
How to watch any changes in object animation svg

Time:09-29

I need to watch changes with att object animation svg

        const windowData = { 
        container: document.getElementById('window-container'),
        renderer: 'svg',
        loop: true,
        autoplay: true,
        path: '/windows.json'
    };
    const windowAnim = bodymovin.loadAnimation(windowData);
    const window2 = windowAnim.isLoaded
    console.log(window2)

I need to write code with if (window2 === true) {...}

but i don't understand how can i watch any changes in this parament isLoaded in svg animation after start page window2 have false and don't changes after animation is loading

CodePudding user response:

According to Lottie documentation, there is an event named data_ready that is fired when all parts of the animation have been loaded. This seems to be what you're looking for.

You would use it as so:

const windowAnim = bodymovin.loadAnimation(windowData);
windowAnim.addEventListener('data_ready', () => {
     /* Your code to run when loaded. */
});
  • Related