【发布时间】:2015-01-22 15:08:59
【问题描述】:
我对 Snap.svg 和 javascript 有疑问。我正在尝试在 mouseEnter 事件上为 svg 设置动画,但在触发事件时出现错误:
Uncaught SyntaxError: Unexpected identifier localhost/:3 Uncaught SyntaxError: 意外的标识符
在这个错误中我发现:
(function(val
/**/) {
return Snap.path.toString.call([[object Array]]) //error in this line
})
我的代码如下所示:
function init() {
var speed = 250,
easing = mina.easeinout;
[].slice.call(document.querySelectorAll('.gallery figure')).forEach(function(el) {
var s = Snap(el.querySelector('svg')),
path = s.select('path'),
pathConfig = {
from: path.attr('d'),
to: el.getAttribute('data-path-hover')
};
el.addEventListener('mouseenter', function() {
path.animate({
'path': pathConfig.to
}, speed, easing);
});
el.addEventListener('mouseleave', function() {
path.animate({
'path': pathConfig.from
}, speed, easing);
});
});
}
【问题讨论】:
-
有没有机会在 jsfiddle 上举个例子?
-
generictec.com/demo/ONE图库部分的蓝色叠加层应该会在鼠标悬停时改变形状。
-
不知道哪个是那里的画廊,项目页面?我那里没有任何错误?顺便说一句,Opera 中的很多页面都被破坏了。
标签: javascript jquery snap.svg