using .animate() - question regarding fluent animation
I have been reading the .animate() function and it is pretty much what I need, but the only problem is that, for example, the following code animates the div (which is what I want) but when the animation starts it starts slowly, then goes faster and then ends slowly again. I need it to be a fluent movement, always at the same speed (for example moving a div 50px to the left in 500 ms). I read something about using "easing: linear" in the options, but it didn't work. I also read on the API examples "
This will only work if you have a plugin that provides this easing function", and I have no idea of what that means exactly. So what would I need to make it work?
- <style>
- .block {
- position:absolute;
- background-color:#abc;
- left:50px;
- width:90px;
- height:90px;
- margin:5px;
- }
- </style>
- <button id="left">«</button> <button id="right">»</button>
- <div class="block"></div>
- <script>
- $("#right").click(function(){
- $(".block").animate({"left": "+=50px"}, { duration: 500 });
- });
- $("#left").click(function(){
- $(".block").animate({"left": "-=50px"}, { duration: 500 });
- });
- </script>