So after roaming around on the web I decided to ask this here.
I'm building an Ionic app for our company, and one of the demands is to apply this animation:
Position + transition - Animation
This is the CSS part:
.background{
background-color:#292930;
}
ul{
list-style:none;
}
.categories{
text-align: center;
position: relative;
height:280px;
width:90%;
}
.categories ul li div{
font-size:18pt;
border-radius:200px;
margin-top:15px;
background-color:#EAEAEA;
height:30px;
width:30px;
-webkit-transform: translate3d(0, 0, 0);
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;
-webkit-transition:1s;
transition:1s;
position: absolute;
display:block;
}
.moveTop {
top:5px !important;
left:77% !important;
}
.categories ul li:nth-child(1) div{left:3%; top:0;}
.categories ul li:nth-child(2) div{left:40%; top:0;}
.categories ul li:nth-child(3) div{left:77%; top:0;}
.categories ul li:nth-child(4) div{left:3%; top:31%;}
.categories ul li:nth-child(5) div{left:40%; top:31%;}
.categories ul li:nth-child(6) div{left:77%; top:31%;}
.categories ul li:nth-child(7) div{left:3%; top:63%;}
.categories ul li:nth-child(8) div{left:40%; top:63%;}
.categories ul li:nth-child(9) div{left:77%; top:63%;}
Basically it works, but super sluggish on iOS or Safari browser, you can even open the fiddle and testify.
After digging around I've seen that you can add
-webkit-transform: translate3d(0, 0, 0);
which should force GPU hardware acceleration, but that did not help.
Afterwards I've read an article by Paul Irish recommending using transform:translate
instead of top
, left
attributes.
So I've tried that, and it did work, very smooth, the problem is, that with translate I need to specify each element, how much it should move compare to itself ( like 30px to the left ), which is pretty unhelpful when I have to support multiple screen sizes.
Any suggestions how to perform this with translate3d or translate or just to make it smooth on Safari?