Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-03-2008, 03:46 PM   PM User | #1
BarrMan
Senior Coder

 
BarrMan's Avatar
 
Join Date: Feb 2005
Location: Israel.
Posts: 1,644
Thanks: 69
Thanked 83 Times in 82 Posts
BarrMan is on a distinguished road
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!
BarrMan is offline   Reply With Quote
Old 09-03-2008, 04:22 PM   PM User | #2
Millenia
Open Source Zealot

 
Join Date: May 2008
Location: Lost in Localhost...
Posts: 702
Thanks: 3
Thanked 43 Times in 42 Posts
Millenia is on a distinguished road
Isn't it just lagging? I don't think you could fix it. Try using something like Flash for animations instead.
Millenia is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:45 AM.


Advertisement
Log in to turn off these ads.