我正在制作悬停效果,包括在mouseEnter和mouseLeave上更改形状。一切正常,但形状从其默认枢轴点变化 - 50%50%。 我想知道如何设置变换原点?我尝试用负y偏移量进行翻译,但无法使其正常工作..
以下是代码:
var s = Snap('svg'),
speed = 200,
easing = mina.easeinout,
path = s.select('path'),
el = document.getElementById('container'),
pathConfig = {
from: path.attr('d'),
to: el.getAttribute( 'data-path-hover' )
},
t = new Snap.Matrix();
path.attr({
cx:-200
});
el.addEventListener('mouseenter', function () {
path.animate({
'path': pathConfig.to ,
'y':120
}, speed, easing);
});
el.addEventListener('mouseleave', function () {
path.animate({
'path': pathConfig.from
}, speed, easing);
});