javascript - Drawer menu performances -


i'm developing side menu web-application (in mobile version) using angular2.

this class when menu closed

.main-drawer {     left: -300px;     width: 300px;     max-width: 100%;     z-index: 2;     transition-property: left;     transition-duration: 300ms;     transition-timing-function: ease-out; } 

when user press open-menu button add following class using jquery

.main-drawer.opened {     left:0;     transition-property: left;     transition-duration: 300ms;     transition-timing-function: ease-out; } 

this js code:

let drawer = jquery ('.main-drawer'); drawer.toggleclass ('opened', !drawer.hasclass ('opened')); 

using code on desktop computers performances good, on mobile version laggy. there way increase per performance?

the menu pretty lightweight, not contain lot of nodes. noticed other websites have pretty performances if menu full of things.

thanks lot

translating x/y more performant transitioning or animation top/left, because translation leans on gpu rendering, powerful , makes movement smooth. top , left operating @ dom level, restrictive.

also, can shorten things little. can define transition in 1 place on initial element , define what's changing in added class. try this:

.main-drawer {     transform: translatex(-300px);     width: 300px;     max-width: 100%;     z-index: 2;     transition: 300ms transform ease-out; }  .main-drawer.opened {     transform: translatex(0); } 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -