I am trying to trigger a rotation animation in SVG on my website. This definitely works, but the problem is that when I move the mouse, when I find the item, it cancels the animation.
So, I include the svg element of the object:
<object type="image/svg+xml" data="branching4.svg" id="branching"> Your browser does not support SVG </object>
which is a long SVG document, but here's a stylesheet attached to it:
#rectangle1, #rectangle2, #rectangle3{ perspective: 1500px; } #rectangle1.flip .card, #rectangle2.flip .card, #rectangle3.flip .card { transform: rotateX(180deg); } #rectangle1 .card, #rectangle2 .card, #rectangle3 .card{ transform-style:preserve-3d; transition:1s; } #rectangle1 .face, #rectangle2 .face, #rectangle3 .face{ backface-visibility: hidden; } #rectangle1 #front1{ transform: rotateX(0deg); } #rectangle1 #back1{ transform: rotateX( 180deg ); } #rectangle2 #front2{ transform: rotateX(0deg); } #rectangle2 #back2{ transform: rotateX( 180deg ); } #rectangle3 #front3{ transform: rotateX(0deg); } #rectangle3 #back3{ transform: rotateX( 180deg ); } #rectangle1.flipped, #rectangle2.flipped, #rectangle3.flipped { transform: rotateX( 180deg ); }
You can see the svg structure in jsfiddle
And finally, the script:
window.onload=function() { var svgDoc = $("#branching")[0].contentDocument; // Get the document object for the SVG $(".st4", svgDoc).css("font-family", "robotolight,Helvetica Neue,Helvetica,Arial,sans-serif"); $("#rectangle1", svgDoc).hover(function(){ $(this, svgDoc).toggleClass("flip"); }); $("#rectangle2", svgDoc).hover(function(){ $(this, svgDoc).toggleClass("flip"); }); $("#rectangle3", svgDoc).hover(function(){ $(this, svgDoc).toggleClass("flip"); }); };
I also tried with CSS, this is the same problem.
Here is the jsfiddle:
https://jsfiddle.net/7f7wjvvt/
1st question:
How can I move on to moving fluid while moving the mouse around an element?
Second question:
How do I have a Y turn that stays in place and doesn't move left? Try the violin
Third question:
Why does jsfiddle display svg in firefox and not in chrome? Also, the prospect doesn't seem to work in chrome ... WHY?
Any ideas?