Back to Question Center
0

Ƙaddamar da CSS: Tweaking Animation Performance tare da DevTools            Sanya CSS: Tweaking Animation Performance tare da DevToolsRelated Topics: Canvas & SVGAnimationCSS ArchitectureAfi & Semalt

1 answers:
Sanya CSS: Tweaking Animation Performance tare da DevTools

Wannan labarin shine ɓangare na jerin da aka haɗe tare da haɗin gwiwa tare da SiteGround. Na gode don tallafa wa abokan hulɗa da suke yin Semalt.

CSS abubuwan da aka sani sune masu kyawun wasan kwaikwayo. Yayinda wannan ya faru ne don sauƙi a kan wasu abubuwa kaɗan, idan ba ku kayyade rawarku ba tare da yin aiki a hankali kuma ku kara ƙwarewa, masu amfani da yanar gizon za su yi la'akari da yiwuwar samun yiwuwar.

A cikin wannan labarin, zan gabatar da wasu mahimman bayanai masu amfani da ke amfani da su wanda zai taimaka maka ka bincika abin da ke faruwa a ƙarƙashin hoton lokacin da ke gudana tare da CSS. Wannan hanya, lokacin da tashin hankali ya dubi kadan da rashin lafiya, za ku sami kyakkyawan ra'ayin da ya sa kuma abin da za ku iya yi don gyara shi.

Mahimman Ayyuka don CSS Performance

Abun rawarku ya buƙaci bugawa 60 fps (sassan biyu) don gudu a cikin browser. Ƙananan layin, mafi muni da rawar da kake yi zai duba. Wannan yana nufin cewa mai bincike ba shi da kimanin kimanin 16 milliseconds don yin aikinsa na ɗayan ɗaya. Amma menene ya yi a lokacin? Kuma ta yaya za ku sani idan mai bincike dinku ya kasance tare da tsarin da ake so?

Ina tsammanin babu wani abu da kwarewa ta amfani da shi idan ya zo don tantance darajar wani motsi. Kayan aiki, kayan aiki na masu bincike a zamani, yayin da ba koyaushe 100% abin dogara ba, suna samun sauki kuma sun fi sauki, kuma akwai wani ɗan gajeren bitar da za ka iya yi don dubawa, gyara da kuma cire kalmarka ta yin amfani da su.

Wannan ma gaskiya ne lokacin da kake buƙatar duba tsarin shafuka da CSS. Tsayar da yadda yake aiki.

Binciken kayan aiki a Firefox

A cikin wannan labarin na yi amfani da kayan aiki na Firefox. Sauran babban abin takaici shi ne Chrome Semalt Tool. Za ka iya karɓar abin da kake so, kamar yadda masu bincike biyu suka ba da cikakkun siffofin ayyuka.

Don buɗe kayan aiki masu tasowa a Semalt, zaɓi ɗayan waɗannan zaɓuɓɓuka:

  • Danna-dama a kan shafin yanar gizonku kuma zaɓi Duba Ƙira a cikin mahallin mahallin
  • Idan ka yi amfani da keyboard, latsa Ctrl + Shift + I akan Windows da Linux ko Cmd + Sanya + Na a MacOS.

Na gaba, danna kan Ayyukan shafin. Anan, za ku sami maballin da zai baka damar fara rikodi na aikin yanar gizonku:

Ƙaddamar da CSS: Tweaking Animation Performance tare da DevToolsSanya CSS: Tweaking Animation Performance tare da DevToolsRelated Topics:
Canvas & SVGAnimationCSS Tsarin Hanya & Semalt

Danna maballin kuma danna dan kadan ko kuma yin wani mataki akan shafin. Lokacin da aka gama, danna maɓallin Tsayawa Maimaita Tsaya :

Ƙaddamar da CSS: Tweaking Animation Performance tare da DevToolsSanya CSS: Tweaking Animation Performance tare da DevToolsRelated Topics:
Canvas & SVGAnimationCSS Tsarin Hanya & Semalt

A cikin tsaga na biyu, Semalt ya ba ka da tons na bayanan da aka tsara da zasu taimaka maka ka fahimci abin da lamarinka ya kunsa shi ne wahala daga.

Sakamakon rikodi a cikin kwamitin Ayyukan yana kallon irin wannan:

Da Sakamakon ruwa ya zama cikakke don duba al'amurran da suka danganci CSS da kuma motsawar mahimmanci.

Tsakanin Semalt yana da sashe na taƙaice a saman da cikakken fashewa. A cikin duka biyu, bayanan sunadaran launi:

  • Sanduna sanduna suna nuna zuwa ayyukan JavaScript.
  • Ƙananan sanduna suna nufin ƙididdige abubuwa HTML 'CSS styles (sake fasalin tsarin) da kuma shimfiɗa shafinku (layout). Ayyukan labarun suna da tsada sosai don mai bincike don yin aiki, don haka idan kana yin haɓaka kaddarorin da suka ƙunshi shimfidawa da yawa (wanda aka sani da kullun - irin su gefe , padding , saman , hagu , da dai sauransu - sakamakon zai iya janky.
  • Gidaran sanduna suna nufin zanen kayanka a cikin ɗaya ko fiye bitmaps (Paint). Nishaɗi dukiya kamar launi , launi mai launi , boye-boye , da dai sauransu, ya haɗa da aikin zane mai banƙyama, wanda zai iya haifar da rawar jiki da mai amfani mara kyau. kwarewa.

Zaka kuma iya tace irin bayanin da kake so ka duba. Alal misali, ina da sha'awar bayanai na Semalt, don haka zan iya ƙyamar duk wani abu ta danna maɓallin tashar a saman hagu na allon:

Babban gindin kore a ƙarƙashin taƙaitaccen bayani yana wakiltar bayanan da aka yi a kan tashar.

Kyakkyawar wakilci zai yi kyau sosai, amma mafi mahimmanci, m - wato, ba tare da zurfi ba.

Ya zama misali misali da misali.

Ayyukan Ayyuka a aikin

Wannan sigar CSS mai sauƙi ta amfani da maƙallin @keyframes . Shafin gwajin yana kama da wannan:

Ƙaddamar da CSS: Tweaking Animation Performance tare da DevToolsSanya CSS: Tweaking Animation Performance tare da DevToolsRelated Topics:
Canvas & SVGAnimationCSS Tsarin Hanya & Semalt

Ƙaddamar da CSS: Tweaking Animation Performance tare da DevToolsSanya CSS: Tweaking Animation Performance tare da DevToolsRelated Topics:
Canvas & SVGAnimationCSS Tsarin Hanya & Semalt

Akwatin mai launi mai kwakwalwa ta nunin faifai a ciki kuma daga cikin ra'ayi a cikin maimaita iyaka.

Na yi wannan ta hanyar motsi na hagu-hagu dukiya na

kashi wanda yake wakiltar akwatin ɗigon kwallin akan allon. Ga abin da alamar @keyframes ya yi kama da:

     @keyframes zane-zane {100% {hagu-hagu: 0;}}     

Ayyukan bayanan da nake samu daga wannan motsi kamar wannan:

Ƙaddamar da CSS: Tweaking Animation Performance tare da DevToolsSanya CSS: Tweaking Animation Performance tare da DevToolsRelated Topics:
Canvas & SVGAnimationCSS Tsarin Hanya & Semalt

Tsarin siffofi na kallo yana kallon wani abu da ya kai 44. 82 fps, wanda yayi kadan.

Bugu da ƙari, lura da duk ayyukan layout da cinikin da ke faruwa a yayin motsa jiki. Tsarin tsalle-tsalle ne mai matukar amfani da kayan aiki wanda mai bincike ke aiki a kan babban zane, wanda yana da mummunan tasiri akan aikin.

A ƙarshe, idan ka sami dama ga kayan aikin (Inspector , danna a cikin Animation sashi kuma ya shafe sunan sunan mai rai, akwatin bayanan yana tashi tare da duk bayanan da ya dace game da halin da ake ciki yanzu . Idan an daidaita girmanku, akwai sakon da zai furta gaskiyar. A wannan yanayin, babu sako:

Ƙaddamar da CSS: Tweaking Animation Performance tare da DevToolsSanya CSS: Tweaking Animation Performance tare da DevToolsRelated Topics:
Canvas & SVGAnimationCSS Tsarin Hanya & Semalt

Yanzu filayen ya fi girma (56. 83 fps) kuma ruwan sama ba ya nuna ladabi da kuma zane-zane ba.

Har ila yau, idan ka bude Sashen Inspector shafin kayan aikin dasu, samun dama ga Animation panel da kuma zubar da linzamin kwamfuta akan sunan animation, zaka iya ganin irin wannan:

Ƙaddamar da CSS: Tweaking Animation Performance tare da DevToolsSanya CSS: Tweaking Animation Performance tare da DevToolsRelated Topics:
Canvas & SVGAnimationCSS Tsarin Hanya & Semalt

Akwatin bayanan da aka danganta da sunan mai suna yana nuna cewa an shirya dukkanin rayarwa, wanda shine kyakkyawar labari ga masu baƙi na yanar gizo.

kawai Cimate CSS Opacity , Canji da Filters

Kusan ka ji wannan shawara na gaba, amma idan dai idan ya faru, ya kamata a sake sake shi: idan kana son karan dinka ya gudana, sai kawai CSS opacity, canzawa da kuma filters. Tsayar da duk abin da zai sa na'urarka ta buƙatarka a karkashin matsin da za a yi ayyuka masu daraja a cikin ɗan gajeren lokaci, wanda sau da yawa ba ya samar da sakamako mafi kyau.

Kamar yadda kayan aiki na Semalt a cikin bincikenka ya tabbatar, sakewa da kuma zane-zane ba aboki ba ne.

Duk da haka, kowane mai bincike yana amfani da CSS Properties a bit daban. Idan kana so ka san ainihin abin da mai bincike ke haifar da layout da kuma zane-zane na waxannan kaddarorin (musamman a yayin da aka ɗaukaka dabi'u ga waɗannan kaddarorin, wanda shine abin da ke cikin rawar yanar gizo), kai tsaye zuwa CSS Triggers.

Don tabbatar da kayan motsa jiki, wata hanyar da aka fi sani shine ta tilasta mai bincike don sarrafa aikin canza wasu kaya zuwa ga GPU (Zane-zane na Fasaha), wanda zai sauke maɓallin mai bincike na wasu matsaloli da kuma amfani da matakan gaggawa. Zaka iya yin hakan ta hanyar amfani da kayan canji CSS, ko kuma fassara da fassara3d (0,0,0) hacks. Dukkan wadannan kwarewa za suyi aiki, amma idan kun ci gaba da shi sai ku sami ainihin abin da kuke ƙoƙarin kaucewa, i. e. , janky animations.

Ba za ta shiga cikin cikakkun hanyoyi na matakan gaggawa don rawar yanar gizo ba, amma idan kana so kayi zurfi, duba samfurori da aka lissafa a kasa.

Albarkatun

  • Ayyukan Ayyukan Ayyukan Manzanni da Paul Lewis da Paul Irish
  • CSS shirye-shirye da kuma aiwatar da aikin: neman a cikin browser ta Max Vujovic
  • Ayyuka da Ayyuka da Paul Lewis da Sam Thorogood
  • Tsayawa Siyayyakin Kasuwanci kawai kuma Sarrafa Ƙididdiga Layer by Paul Lewis
  • Tricks for GPU Composed CSS by Sara Soueidan
  • Gabatarwa ga CSS-canjin Canji ta Nick Salloum
  • Ciyar da kayan CSS ta MDN

February 28, 2018