I'm a front-end developer in GlobalLogic Ukraine.
GitHub: dnbard
Skype: dnbard
24 fps / 41.67 ms
60 fps / 16.67 ms
up to
84 fps / 11.9 ms
( javascript )
( transitions and animations in CSS )
16.66 ms
If you would change any property that would involve any change in Layout (geometry, width, height, positioning) then full cycle of Pixel Conveyor would be involved.
Styles that affects Layout:
width height
padding margin
display border-width
border top
position font-size
float text-align
overflow-y font-weight
overflow left
font-family line-height
vertical-align right
clear white-space
bottom min-height
Changing an element may also trigger painting. Depending on how the elements in your app are grouped into layers, other elements besides the one that changed may also need to be painted.
color border-style
visibility background
text-decoration background-image
background-position background-repeat
outline-color outline
outline-style border-radius
outline-width box-shadow
background-size
4 things that Browser can animate fast:
Position - transform: translate(x, y);
Scale - transform: scale(n);
Rotation - transform: rotation(deg);
Opacity - 0...1;
transform: translateZ(0);
Hack to create a new layer.
New Layer is created if element:
Layout Thrashing occurs when JavaScript writes, then reads, from the DOM, multiple times causing document reflows.
// Read
var h1 = element1.clientHeight;
// Write (invalidates layout)
element1.style.height = (h1 * 2) + 'px';
// Read (triggers layout)
var h2 = element2.clientHeight;
// Write (invalidates layout)
element2.style.height = (h2 * 2) + 'px';
// Read (triggers layout)
var h3 = element3.clientHeight;
// Write (invalidates layout)
element3.style.height = (h3 * 2) + 'px';
// Read
var h1 = element1.clientHeight;
var h2 = element2.clientHeight;
var h3 = element3.clientHeight;
// Write (invalidates layout)
element1.style.height = (h1 * 2) + 'px';
element2.style.height = (h2 * 2) + 'px';
element3.style.height = (h3 * 2) + 'px';
// Document reflows at end of frame
var h1 = element1.clientHeight;
// Write
requestAnimationFrame(function() {
element1.style.height = (h1 * 2) + 'px';
});
// Read
var h2 = element2.clientHeight;
// Write
requestAnimationFrame(function() {
element2.style.height = (h2 * 2) + 'px';
});
Use requestAnimationFrame!
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord.xy / iResolution.xy;
fragColor = vec4(uv,0.5+0.5*sin(iGlobalTime),1.0);
}