Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I add aceleration to this jQuery animation?
    primarykey
    data
    text
    <p>I was able to animate my <code>&lt;div&gt;</code> ( <a href="https://stackoverflow.com/questions/7121147/slideup-only-hides-cant-show-using-slideup">more info</a> ) from <code>bottom:-100px</code> to <code>bottom:0px</code>.</p> <p>Now I'd like to have different speeds: Start a bit slower at the beginning of the animation and then get faster by the end of the animation.</p> <p>This is how it looks:</p> <pre><code>$('#bannerFijo').animate({ bottom: '-15px' }, 1000, function() { $('#bannerFijo').animate({ bottom: '0px' }, 100); }); </code></pre> <p>But I'm sure there must be another way so that the speed changes progressively.</p> <p>-edit-</p> <p>Animated version two:</p> <pre><code>$('#bannerFijo').animate({ bottom: '0px' }, 1200, function() { $('#bannerFijo').animate({ bottom: '-15px' }, 300,function() { $('#bannerFijo').animate({ bottom: '-5px' }, 150,function() { $('#bannerFijo').animate({ bottom: '-10px' }, 100,function() { $('#bannerFijo').animate({ bottom: '0px' }, 50); return true; }); }); }); }); </code></pre> <p>-Edit- Thanks to SuperPaperSam i got to this solution ('no' plugins)</p> <pre><code>$.easing.easeOutBounce = function (x, t, b, c, d) { if ((t/=d) &lt; (1/2.75)) { return c*(7.5625*t*t) + b; } else if (t &lt; (2/2.75)) { return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; } else if (t &lt; (2.5/2.75)) { return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; } else { return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; } } </code></pre> <p>So the animate function look like this:</p> <pre><code>function mostrar_banner(){ $('#bannerFijo').animate({ bottom: '+=110px' }, 2000, 'easeOutBounce'); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload