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

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 01-11-2010, 12:26 PM   PM User | #1
tobieggger
New to the CF scene

 
Join Date: Jan 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
tobieggger is an unknown quantity at this point
Object position changes on mousemove. Failed to set up easing.

Hello there,

Obviously I've a problem

An object's position is updated relatively to mouseposition on
mousemove (opposite direction). Works perfectly well, but I failed to
set up the code with smooth easing as result. The code works in
Actionscript in Flash (of course in proper syntax) but it doesn't work
in jQuery syntax and code-elements. Strange is that nearly the same
code works in Actionscript and there WITH easing
In jQuery, I used "css()" to position the object, "animate() with
easing" produces a messy animation.

Any idea how I could implement an easing to this animation?

Code:
$().mousemove(function(e){ 

    $(".object").each(function(){ 

        var position = $(this).offset(); 
        var position_x = position.left; 
        position_x = 0; 

        var windowwidth = ($(window).width()/2); 
        var endX = (windowwidth)-(e.pageX); 

        var speed = 5; 
        position_x += (endX-position_x)/speed; 

        $(this).css({'left':position_x}); 

}); });
Br,
Tobie

Last edited by tobieggger; 01-12-2010 at 03:51 PM..
tobieggger 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 10:45 PM.


Advertisement
Log in to turn off these ads.