Reputation: 2207
I am looking for a solution to animate a element from width 0 to width 100% using jquery animate(I think this is not the right solution for this). The bigger the element gets the slower should the animation go, so the speed of the animation should slow down more when the element gets bigger. There isn't much demo code to give you so I really hope that somebody does understand what I am trying to build.
// the code(not the best way to do something like this)
$('.element').animate({width: '20%'},2000,function(){
$('.element').animate({width: '40%'},4000,function(){
$('.element').animate({width: '60%'},8000,function(){
$('.element').animate({width: '80%'},16000,function(){
$('.element').animate({width: '100%'},32000,function(){
});
});
});
});
});
Using easing does not do the trick!
Upvotes: 1
Views: 73
Reputation: 4624
Try this
var height = $('.element').height(),
seconds = 1,
minRange = 500,
maxRange = 1500;
time = height * seconds;
time = Math.min(time, maxRange);
time = Math.max(time, minRange);
$('.element').animate({width: '100%'},time);
Upvotes: 2
Reputation: 7475
you can try use linear
$('.element').animate({width: '100%'},1000 'linear')
Upvotes: 0