css - background-size cover makes css3 animation choppy -


i have grid of images want animate top css3. works until put background-size: cover onto grid. animation becomes choppy. doing wrong, or can prevent this?

when use jquery's animation function becomes worse.

i found like: -webkit-backface-visibility:hidden; not trick.

example: http://jsfiddle.net/pqdvz/

body{     overflow: hidden;     margin: 0;     padding: 0;     background: #ccc; }  div.container.animate{     top:-100%; } div.container{     position: absolute;     right: 0;     bottom: 0;     top: 0;     left: 0;     -webkit-transition: top 1s ease-in-out;     -moz-transition: top 1s ease-in-out;     -o-transition: top 1s ease-in-out;     -ms-transition: top 1s ease-in-out;     transition: top 1s ease-in-out;  }  ul{    display: block;     padding: 0;     margin: 0; }  li{     width: 25%;;     float: left;     height: 160px;     background-size: cover;     list-style: none;     margin: 0;     padding: 0; } 

there nothing wrong javascript, problems lays in css. animating top, right, bottom , left hardware accelerated. bad because run on cpu , not on gpu. when see jerky transition can bet not hardware accelerating. instead should use hardware acceleration.

instead of animating top, should animate transform(x, y, z). will make hardware accelerated.

so have change following css:

div.container.animate{     top:-100%; }  div.container{     position: absolute;     right: 0;     bottom: 0;     top: 0;     left: 0;     -webkit-transition: top 1s ease-in-out;     -moz-transition: top 1s ease-in-out;     -o-transition: top 1s ease-in-out;     -ms-transition: top 1s ease-in-out;     transition: top 1s ease-in-out; } 

into this:

div.container{     float: left;     width: 100%;     height: 100%;      -webkit-transform: translate3d(0, 0%, 0);        -moz-transform: translate3d(0, 0%, 0);         -ms-transform: translate3d(0, 0%, 0);          -o-transform: translate3d(0, 0%, 0);             transform: translate3d(0, 0%, 0);      -webkit-transition: 1s ease-in-out;        -moz-transition: 1s ease-in-out;          -o-transition: 1s ease-in-out;         -ms-transition: 1s ease-in-out;             transition: 1s ease-in-out; }  div.container.animate{     -webkit-transform: translate3d(0, -100%, 0);        -moz-transform: translate3d(0, -100%, 0);         -ms-transform: translate3d(0, -100%, 0);          -o-transform: translate3d(0, -100%, 0);             transform: translate3d(0, -100%, 0); } 

here live link: http://jsfiddle.net/pqdvz/1/


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -