速度未定义

Dan*_*vis 5 javascript jquery velocity.js

我放弃.如何定义Velocity?这些例子都没有表明这一点,而且是正确的; 它应该很容易.我试图在没有JQuery的情况下使用速度版本1.2.3(根据GitHub在九天前发布).我通过从GitHub直接下载到我的网页获得了第一个版本(较早版本,1.2.2),然后将我的网页保存为velocity.js.第二个是通过访问https://github.com/julianshapiro/velocity,访问velocity.js并将其保存为Velocity123.js获得的.

这个测试程序是为了帮助我开始使用velocity,但由于FireFox v 40.0.3的webdeveloper/webconsole报告,由于Velocity未定义的情况,我还不能到达那里.Velocity undefined的另一个FAQ实例似乎不适用,因为他使用的是JQuery的过时版本.在velocity1.2.3中,我已经看到了Velocity的实际定义,我已经找到了该文件.我已经通过复制它来测试文件定义,并在更改/到\之后将它DIR在shell中,那么如何才能定义?测试代码是:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title>Test1 Velocity</title>
        <meta charset="utf-8"/>
        <!-- Standard download from GitHub
           <script src="C:/Users/dbd/Documents/Library4thFloor/velocity.js"> 
           </script> 
        -->
        <!-- Suggested by wikipedia 
           <script src="//cdn.jsdelivr.net/velocity/1.2.2/velocity.min.js">
           </script> 
         -->
        <!-- manually included from github latest -->
        <script src="C:/Users/dbd/Documents/Library4thFloor/Velocity123.js"> 
        </script>
        <script type="text/JavaScript">
           function press(){
             alert("entered press");
             var idrect = document.getElementById("sq");
             alert("after idrect is set");
             Velocity(idrect, {opacity:0.3},{duration:2,easing:"ease-in-out",loop:5});
             return false;
           } 
        </script>
    </head>
    <body>
        <h1>Sample SVG with Velocity</h1>
        <br>
      <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="400" height="400">
        <rect id="sq" 
              x="25" 
              y="25" 
              width="200" 
              height="200" 
              fill="lime" 
              stroke-width="4" 
              stroke="pink"
              onclick="press()"
        />
      </svg>
    </body>
    </html>
Run Code Online (Sandbox Code Playgroud)

roy*_*wie 3

快速阅读velocity.js文档就会发现您做错了什么。Velocity 的使用方式与其他 jQuery 方法类似。

例如,如果您想要先div红后蓝,每个动画 1000 毫秒:

$('div')
    .velocity({ backgroundColor: 'red' }, 1000)
    .velocity({ backgroundColor: 'blue' }, 1000)
Run Code Online (Sandbox Code Playgroud)