Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts

    Image gets jammed (a bit) while moving

    Hey,
    I'm trying to make a moving image inside a frame. And it works.
    The only problem is, that while the images moves, it gets jammed on some parts and moves on.

    I'd like the image to have a smooth motion.

    Here's a link so you could see it in action:
    http://www.imri-tech.net/splusw/

    Here's the code:
    Code:
    function moveImage()
    {
        var p = Math.PI*2;
        var st = new Date().getTime();
        var dir=1;
        var frq = 1/3000;
        var s = 0;
        var obj = $("moving_image");
        window.setInterval(
        function()
        {
            var et = new Date().getTime()-st;
            var d = et*frq;
            /*if(et*5000>7000)
                $("moving_image").src = */
                if(s==0)
                    obj.style.top = -100+d*100+"px";
                if(s==1)
                    obj.style.left = -152+d*152+"px";
                if(s==2)
                    obj.style.top = -d*100+"px";
                if(s==3)
                    obj.style.left = -d*152+"px";
                if(d>=1)
                {
                    s++;
                    st = new Date().getTime();
                }
                if(s>3)
                    s=0;
            
        },5);
    }
    Thanks!

  • #2
    Regular Coder
    Join Date
    May 2008
    Location
    Lost in Localhost...
    Posts
    702
    Thanks
    3
    Thanked 43 Times in 42 Posts
    Isn't it just lagging? I don't think you could fix it. Try using something like Flash for animations instead.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •