Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery seesaw effect

Tags:

jquery

css

I am trying to do a seasaw effect with Jquery, but need some help with which plugin to use. I want the bar to go up and down and the box on the top to move with it. here is my code on JsFiddler: http://jsfiddle.net/semantic/LscQd/4/

Thanks

like image 282
JAML Avatar asked Jul 27 '26 14:07

JAML


2 Answers

Using the jQuery Rotate plugin, I was able to get the teeter-totter effect with an interval and a timeout:

setInterval(function(){
    $(".bar").rotate({animateTo:15});
    $(".box").animate({left:284},1000);
    setTimeout(function(){
        $(".bar").rotate({animateTo:-15});
        $(".box").animate({left:0},1000);        
    }, 1000);
}, 2500);​

Fiddle: http://jsfiddle.net/LscQd/10/

like image 94
Sampson Avatar answered Jul 30 '26 02:07

Sampson


Quick attempt, not great I know but should be useful as a starting point. Uses css transforms to rotate seesaw between -30 and 30 degrees. Hope it helps

http://jsfiddle.net/czAHU/1/

edit: animating the bar instead looks much better than the whole wrapper. in all honesty though i didnt expect it to move the box too, so i might be a bit more cautious about it... http://jsfiddle.net/czAHU/2/

like image 36
Jordan Wallwork Avatar answered Jul 30 '26 04:07

Jordan Wallwork



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!