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 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.


 

Posting Permissions

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