Reputation: 3
$(document).ready(function(){
var el = $("#box");
animate(el,300,function(){
});
});
function animate(el,leftVal,callback){
el.animate({
left : leftVal
},{
duration : 2000,
queue : false,
easing : "swing",
complete : function(){
//alert("finished");
if(callback){
callback();
}
}
});
}
Upvotes: 0
Views: 174
Reputation: 17061
Add a duration
parameter to your function:
function animate(el, leftVal, callback, duration) {
Then call the parameter in the duration part of the function:
{
duration: duration,
...
}
When you're calling the function, define the last parameter (which is now the duration):
$(document).ready(function() {
var el = $("#box");
animate(el, 300, function() {
},1000); // 1 second duration (1000 milliseconds)
});
Upvotes: 1