css3 - CSS `will-change` - how to use it, how it works -


i found css will-changew3.org docs, mdn docs property (which works in chrome , partiali supported firefox , opera) i'm not sure how works. know more mysterious thing?

i have read allows browser prepare calculation on element in future. don't want misunderstand it. have few questions.

  1. should add property element class or hover state?

    .my-class{     will-change: 'opacity, transform' } .my-class:hover{     opacity: 0.5 } .my-class:active{     transform: rotate(5deg); } 

    or

    .my-class{     ... } .my-class:hover{     will-change: 'opacity'     opacity: 0.5 } .my-class:active{     will-change: 'transform'     transform: rotate(5deg); } 
  2. how can increase browser performance? theoretically, when css loaded, browser "knows" happen each element, doesn't it?

if can add example illustrating how use efficiently, grateful :)

i won't copy paste entire article here here's tl;dr version:

specifying want change allows browser make better decisions optimizations needs make these particular changes. better way achieve speed boost without resorting hacks , forcing browser layer creations may or may not necessary or useful.

how use it: da

will-change: transform, opacity; 

how not use it:

will-change: all;  .potato:hover {   will-change: opacity;   opacity:1; } 

specifying will-change on hover has no effect:

setting will-change on element before changes has little no effect. (it might worse not setting @ all. incur cost of new layer when you’re animating wouldn’t have qualified new layer!)


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -