Home › Forums › JavaScript › Change function animation duration? › Reply To: Change function animation duration?
December 18, 2013 at 2:31 pm
#158645
Participant
Thanks for the suggestion…seems like a nice and simple solution. I’ll give it a try in a short time and see how it works.
One thing —
I’m a bit confused about the variable syntax…specifically duration ? duration : 600
. You mentioned below: it’s saying that speed is the duration value that gets passed through, but if that doesn’t exist let’s just use 600. I don’t quite understand how the question mark works though.
One more —
Could the speed variable be defined outside the function and still be accessed properly?
For example:
var speed = (duration ? duration : 600);
$.fn.extend({
funkOne: function(duration) {
$(this).animate({ scrollTop: 0 }, speed);
},
funkTwo: function() {
$('div').funkOne(300);
},
funkThree: function() {
$('p').funkOne(900);
}
});
Thanks for your help :)