Element.hover(f_in, f_out, [icontext], [ocontext])

给元素添加hover事件。


参数
  • f_in 函数。hover进入的事件句柄。
  • f_out 函数。hover出来的事件句柄。
  • icontext 函数。hover进入事件句柄的上下文。
  • ocontext 函数。hover出来事件句柄的上下文。

返回值

对象。元素。


使用
<svg id="svg" width="100" height="100"></svg>
var svg = Snap("#svg");
var c = svg.paper.circle(50, 50, 40).attr({
    fill: "#f00"        // 红色
}).hover(function() {
    // 移入
    this.animate({
        fill: "#00f"    // 蓝色
    }, 1000);   
}, function() {
    // 移出
    this.animate({
        fill: "#f00"    // 红色
    }, 1000);   
});