gpt4 book ai didi

javascript - Raphael JS -- 动画 .text()

转载 作者:数据小太阳 更新时间:2023-10-29 03:54:39 26 4
gpt4 key购买 nike

所以我正在使用 Raphael JS 来尝试 animate .

这是我尝试过的:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://raphaeljs.com/raphael.js"></script>
<script type="text/javascript">
$(window).load(function () {
var R = Raphael("holder", 640, 480);
var test = R.text(200, 200, "Test string");
test.animate({cx: 20, cy: 20}, 2000);

});
</script>
</head>
<body>
<div id="holder">
</div>
</body>
</html>

而我的文字仍然是 200,200。关于为什么这行不通的任何想法?

最佳答案

animate 函数只能对某些属性进行动画处理,并且只能对属于该特定对象的属性进行动画处理。

文本对象没有 cx 或 cy 属性 - 因此您的示例代码不会设置动画。

您只能翻译文本对象,因为它只有 x、y 和文本属性。

http://raphaeljs.com/reference.html#text

如果您尝试翻译文本,请像这样使用 x 和 y 属性:

test.animate({x:20, y:20}, 2000);

关于javascript - Raphael JS -- 动画 .text(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3637353/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com