javascript - snap svg animate to original size and position -
when user hover baloon svg, want animate baloon svg (make bigger).
, when user unhover baloon, baloon return original size.
use reset original size , position.
transform: 's1'
it work in chrome, firefox, safari.
but when tried on ie, expand animation work, reset animation doesn't work, blinked original size without animation.
$balooncolumn.on('mouseenter', function() { animateexpandbaloon(); }); $balooncolumn.on('mouseleave', function() { animatenormalbaloon(); }); var animateexpandbaloon = function() { baloonshout.animate({ transform: 's1.1t5,10' }, 1000, mina.elastic); baloon.animate({ transform: 's1.05t' }, 1200, mina.elastic); baloonrighteye.animate({ transform: 's1t3,-2' }, 1200, mina.elastic); baloonlefteye.animate({ transform: 's1t3,-2' }, 1200, mina.elastic); baloontail.animate({ transform: 's1t15,0' }, 1200, mina.elastic); baloonmouth.animate({ transform: 's1.15t' }, 1200, mina.elastic); } var animatenormalbaloon = function() { baloonshout.animate({ transform: 's1' }, 1000, mina.elastic); baloon.animate({ transform: 's1' }, 1200, mina.elastic); baloonrighteye.animate({ transform: 's1' }, 1200, mina.elastic); baloonlefteye.animate({ transform: 's1' }, 1200, mina.elastic); baloontail.animate({ transform: 's1' }, 1200, mina.elastic); baloonmouth.animate({ transform: 's1' }, 1200, mina.elastic); }
how should element animated original size , position correctly?
firstly think shoud use snap hover function; http://snapsvg.io/docs/#element.hover
i doing kinda same thing im pretty sure, , found way through setting custom attributes of elements animated. needed many different states , may not elegant solution, works, , svg specs allow setting custom attributes on paths. since setting transforms svg data dynamically, able set attrs on creation.
so, how came;
element.attr('state-static',my-static-state-string);
and then;
element.hover( function(){ element.animate('transform':'t15,0'); },function(){ element.animate('transform':element.attr('state-static')); })
let me know if helped you
Comments
Post a Comment