css3動畫——基本準則

來源:互聯網
上載者:User

標籤:style   io   os   使用   ar   for   檔案   sp   c   

Guidelines for animation
  1. Use CSS keyframe animation or CSS transitions, if at all possible. The browser can optimize painting and compositing bigtime here.
  2. If needs to be it’s JS-based animation, use requestAnimationFrame. Avoid setTimeoutsetInterval.
  3. Avoid changing inline styles on every frame (jQuery animate()-style) if you can, declarative animations in CSS can be optimized by the browser way more.
  4. Using 2D transforms instead of absolute positioning will typically provide better FPS by way of smaller paint times and smoother animation.
  5. Use Timeline Frame’s mode to investigate what is slowing down your behavior
  6. “Show Paint Rects” and “Render Composited Layer Borders” are good pro-moves to verify where your element is being rendered.
動畫準則
  1. 在條件允許的情況下用keyframe animation 或者css transition 代替其他方式(比如settimeout,requestAnimationFrame,雖然後者效能已經很高了)瀏覽器可以實現最佳化繪製把重複工作整合
  2. 如果需要使用js定時器,請使用requestAnimationFram,避免使用settimeout和setinterval
  3. 避免在元素上直接改變內聯style(就像jquer的animate()乾的那樣)如果可以,在css檔案內聲明動畫將會更多的得到瀏覽器的最佳化方案支援
  4. 使用2Dtransform代替position:absolute動畫,這樣將會得到更好的fps幀和更流暢的動畫效果(確保display:block或者display:inline-block)
  5. 使用 Timeline Frame’s模式(chrome內)檢查是什麼原因導致效能不足
  6. 使用“Show Paint Rects”和 “Render Composited Layer Borders”功能(chrome 的 rendering內)是一種不錯的方式去查看你的頁面元素渲染過程

css3動畫——基本準則

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.