position -> transform: translate(npx, npx);
scale -> transform: scale(n);
rotate -> rotate: rotate(ndeg);
opacity -> opacity: 0...1;
The process a website is loaded:
- Function call;
- Recalculate style;
- Layout: generate geometry and position;
- Paint: fill out the pixels for each elements into layers;
- Composite Layers: draw layers out to the screen;
Position, scale, rotate and opacity only change properties that affect compositing stage, which makes them cheap.
And Chrome, Firefox, Safari and Opera all hardware accelerate transforms and opacity.
This is a good reference to find out which exact stage a css property affects:
Opacity must be only one in the layer in order not to change background of others. Blink and Webkit browsers will automatically create a layer for opacity changes, but translateZ(0) and translate3d(0, 0, 0) are also used to create a new layer manually.
As to change position, setting left and top directly will change layout, so remember to use translate.
No comments:
Post a Comment