I am using Jquery UI’s draggable and I put the revert feature on.
By default, the div reverts in a ‘swing’ motion,
I am wondering how can i make the div revert in a linear motion.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t use the regular revert method on the draggable to get a custom return easing because it only supports changing the duration. If you want to make the revert have a custom effect, you need a little custom code as below, and plug in any of the custom easing effects from the JQueryUI showcase http://jqueryui.com/demos/effect/#easing.
Note that in the stop method, I made the easing effect be easeInElastic to highlight the difference, but you can change it to whatever you want (linear in your case).
Note that you will need to include JQuery UI to get those effects.
http://jsfiddle.net/gregjuva/Hjf8p/