Git Product home page Git Product logo

Comments (15)

bodymovin avatar bodymovin commented on May 7, 2024

@berendvaneerde Hi. I think the loadAnimation method might work for you.
you pass an object with the necessary params (look on the readme file for all the possible configurations). You can set the autoplay and loop flags to false on your case.
It returns an animation instance you can control and call the play, stop, pause, gotoAndStop and other methods on it.
I will update the documentation to reflect this.

from lottie-web.

berendvaneerde avatar berendvaneerde commented on May 7, 2024

Thank you for your quick response.
I tried the loadAnimation method before, but no succes. I am not sure how to load the json file in animationData param: do I just route to it?
like: {animationData: JSON.parse('../animations/logo_reveal/data.json')}

from lottie-web.

bodymovin avatar bodymovin commented on May 7, 2024

@berendvaneerde Instead of using animationData, use path and pass the json path.
something like:
bodymovin.loadAnimation({
wrapper: element, // the dom element
animType: 'svg',
loop: true,
autoplay: true,
path: '../animatoins/logo_reveal/data.json'
});

It's not on the documentation either :/
I'll update it.

from lottie-web.

berendvaneerde avatar berendvaneerde commented on May 7, 2024

Thanks for your help. Getting further

Still no luck though: I get the following error

Uncaught TypeError: this.animationItem.wrapper.appendChild is not a function
SVGRenderer.configAnimation @ bodymovin.js?ver=4.2.5:2
AnimationItem.configAnimation @ bodymovin.js?ver=4.2.5:4
AnimationItem.setParams.r.onreadystatechange @ bodymovin.js?ver=4.2.5:4

from lottie-web.

bodymovin avatar bodymovin commented on May 7, 2024

@berendvaneerde what did you pass as wrapper? you need to pass a dom element.

from lottie-web.

berendvaneerde avatar berendvaneerde commented on May 7, 2024

as following

var logoReveal = $('#logoreveal'); //corresponding to a dom element in my html

bodymovin.loadAnimation({
  wrapper: logoReveal, // the dom element
  animType: 'svg',
  loop: false,
  autoplay: true,
  path: 'wp-content/themes/botoboto/library/animations/logo_reveal/data.json'
});

from lottie-web.

berendvaneerde avatar berendvaneerde commented on May 7, 2024

GOT IT! appears that my jquery doesn't work... Does it need to be pure javascript?

from lottie-web.

bodymovin avatar bodymovin commented on May 7, 2024

@berendvaneerde nice!
yes, for the moment it only supports pure javascript.

from lottie-web.

berendvaneerde avatar berendvaneerde commented on May 7, 2024

aha! So how about calling bodymovin.play('name') inside a jquery function?
Is that the reason why that is not working?

from lottie-web.

bodymovin avatar bodymovin commented on May 7, 2024

@berendvaneerde no, I think that might be another issue. If you have a working example, I'll take a look.

from lottie-web.

berendvaneerde avatar berendvaneerde commented on May 7, 2024

I'm on the right track now! Thanks to your hint on the gotoAndStop method. Logical to reset the animation to a starting point, before you can play it again, but I never saw that method before your post ;) I've got a mouseover working now. Is there also a method to give the animation another frame at load or so?

Perhaps I just need to dive into the code more, but your plugin definitely deserves some more documentation on these methods as well! All in time of course :) Thanks very much for your help. I feel like I can go to bed now with this little victory!

from lottie-web.

bodymovin avatar bodymovin commented on May 7, 2024

@berendvaneerde what do you mean by giving another frame at load? to display another frame by default on load?
I'm glad it works :)

from lottie-web.

berendvaneerde avatar berendvaneerde commented on May 7, 2024

yes! That's what I mean

from lottie-web.

bodymovin avatar bodymovin commented on May 7, 2024

@berendvaneerde no it doesn't but it makes sense. I'll add it to my todo list

from lottie-web.

berendvaneerde avatar berendvaneerde commented on May 7, 2024

Great! Thanks again...

from lottie-web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.