2012-06-25 152 views
2

我是新来的拉斐尔,我正在尝试做一些非常简单的事情,但很失败。拉斐尔动画

我想在this link这个复制的动画是我到目前为止的代码:

<html> 
<head><title></title> 
<script src="raphael-min.js"></script> 
<script src=" src="jquery-1.7.2.js"></script> 
</head> 

<body> 

<div id="draw-here-raphael" style="height: 200px; width: 400px; background: #666;"> 
</div> 

<script type="text/javascript"> 
//all your javascript goes here 

var r = new Raphael("draw-here-raphael", 400, 200), 

    // Store where the box is 
    position = 'left', 

    // Make our pink rectangle 
    rect = r.rect(20, 20, 50, 50).attr({"fill": "#fbb"}); 

// Note JQuery is adding the mouseover. SVG == html nodes 
$(rect.node).mouseover(function() { 
    if (position === 'left') { 
    rect.animate({x: 300, y: 100}, 400, "<>"); 
    position = 'right'; 
    } else { 
    rect.animate({x: 20, y: 20 }, 800, "bounce"); 
    position = 'left'; 
    } 
}); 
// Make that sucker rotate 
setInterval(function() { 
    rect.rotate(1); 
}, 10); 

</script> 

</body> 
</html> 

我已经下载了jQuery和有它在同一文件夹中的拉斐尔。不工作的代码是关于jQuery添加鼠标悬停的评论代码。当我添加该代码矩形不再旋转。它只是静止的。如果有人可以请这个动画帮助我,我将不胜感激。

感谢

+2

您是否看到以下错误信息:

回答

4

你在代码中有一个错误:

<script src=" src="jquery-1.7.2.js"></script> 

将其更改为:

<script src="jquery-1.7.2.js"></script> 

这应该纠正与jQuery你的问题。

+0

啊,是的,谢谢,现在动画正在运行,但它不会到达底部页面的右侧,它会向左或向下移动并消失任何想法? –