" L"方向javascript动画

时间:2016-02-25 08:58:23

标签: javascript animation

我想让我的动画有一个" L"方向。下降后,它将向右移动。但是当我尝试这样做时,它只会在对角线路径上移动。

(function () {    
    var speed = 50,
        walkingCat = document.getElementById("catwalk"),
        catWalk = function () {    
            left = walkingCat.offsetLeft,
            moveBy = 10;    
            walkingCat.style.left = left + moveBy + "px";    
        if (left > 850) {
            clearInterval(timer);
        }
    };    
    var timer = setInterval(catWalk, speed);        
    var catWalkDown = function () {            
        var top = walkingCat.offsetTop,
            moveBy = 10;    
            walkingCat.style.top = top + moveBy + "px";    
        if (top > 850) {
            clearInterval(timer2);
        }
    };    
    var timer2 = setInterval(catWalkDown, speed);       
} ());

1 个答案:

答案 0 :(得分:0)

试试这种方式 -

<强> HTML

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /sitegroup/
    RewriteRule ^pages/GA/GA_Be\.shtml$ http://www.example.com/sitegroup/garten-und-landschaftsbau/#gartenforum-ideengarten [R=301,L,NE]
    RewriteRule ^pages/GA/GA_Bg\.shtml$ http://www.example.com/sitegroup/garten-und-landschaftsbau/#gartenplanung-landsc‌​haftsplanung [R=301,L,NE]
    RewriteRule ^pages/GA/GA_En\.shtml$ http://www.example.com/sitegroup/garten-und-landschaftsbau/#erdsondenbohrung-erd‌​waerme [R=301,L,NE]
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /sitegroup/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /sitegroup/index.php [L]
</IfModule>
# END WordPress

并且在 的 JS

<div id="catwalk" style="position:relative;width:5px;height:5px;background:black"> </div>