Hi there!
I try to do a hover effect directly with an animation from ae. I don麓t know why, but it doesn麓t work... (That what I have written). Could you help me?
`var animation = bodymovin.loadAnimation({
container: document.getElementById("logo").addEventListener("mouseover", function(){ anim.play(); }),
renderer: "svg",
loop: true,
autoplay: false,
prerender: true,
path: "json/logo.json"
})`
Could I a svg image (logo) in the html embed and render the animation (json data) as hover?
Thank you! :)
your animation instance is called "animation", have you tried doing animation.play() instead of anim.play() ?
Yes I did it, but with the same result... Maybe is it an animation麓s problem?
Does putting these separate work:
var logo = document.getElementById("logo");
var animation = bodymovin.loadAnimation({
container: logo,
renderer: "svg",
loop: true,
autoplay: false,
prerender: true,
path: "json/logo.json"
});
anim.addEventListener('DOMLoaded', function(){
logo.addEventListener("mouseover", function(){ anim.play(); });
}
Hey! It麓s alive, thank you so much!
That麓s what I wrote (maybe can it help someone ;)):
`var logo = document.getElementById("logo");
var animation = bodymovin.loadAnimation({
container: logo,
renderer: "svg",
loop: true,
autoplay: false,
prerender: true,
path: "json/logo.json"
});
logo.addEventListener("mouseenter", function () {
animation.play();
});
logo.addEventListener("mouseleave", function () {
animation.stop();
});`
Most helpful comment
Hey! It麓s alive, thank you so much!
That麓s what I wrote (maybe can it help someone ;)):
`var logo = document.getElementById("logo");
var animation = bodymovin.loadAnimation({
container: logo,
renderer: "svg",
loop: true,
autoplay: false,
prerender: true,
path: "json/logo.json"
});
logo.addEventListener("mouseenter", function () {
animation.play();
});
logo.addEventListener("mouseleave", function () {
animation.stop();
});`