代码之家  ›  专栏  ›  技术社区  ›  Incognito

Raphael JS-动画.text()

  •  9
  • Incognito  · 技术社区  · 14 年前

    所以我用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>
    

    我的课文还是200200。你有没有想过为什么这样不行?

    1 回复  |  直到 14 年前
        1
  •  5
  •   John    14 年前

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

    文本对象没有cx或cy属性,因此示例代码将不会产生动画效果。

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

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

    如果要翻译文本,请使用以下X和Y属性:

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