Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><s>I'm not sure if some properties create less overhead while animating than others but</s> I would be very interested if someone posts some good information on that subject. That being said I do know of a couple things that can help performance.</p> <p>Setting <code>position : absolute</code> removes the element from the regular flow of the page and therefore does not require the entire page to be redrawn when it is animated. <code>position : relative</code> will force a redraw of the whole page since ancestor and descendant elements can be affected.</p> <p>Also, you can throttle the <code>scroll</code> event and still achieve 30fps:</p> <pre><code>var scroll_ok = true; setInterval(function () { scroll_ok = true; }, 33);//33ms is 30fps, you can try changing this to something larger for better performance $(window).bind('scroll', function () { if (scroll_ok === true) { scroll_ok = false; //now run your code to animate with respect to scroll } }); </code></pre> <p><strong>UPDATE :: 2014-08-26</strong></p> <p>Things have changed since this was originally written. A few quick notes:</p> <ul> <li><p>Modern browsers now attempt to GPU accelerate the painting of elements given a specific set of properties (<code>opacity</code> and <code>transform</code> off the top of my head). Using these properties can greatly improve performance over others like <code>top</code>/<code>left</code> (which also require redrawing the page in more instances than using a <code>transform</code>).</p></li> <li><p><code>will-change</code> is a new property just being picked up by browsers. You can basically set a list of properties that are likely to change so the browser can optimize the property change ahead of time.</p></li> <li><p><code>requestAnimationFrame</code> has a robust polyfill and good modern browser support. This is a much better way to smoothly animate elements without creating tons of "chunk" as the browser will render as it can.</p></li> </ul>
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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