How to improve the sidenav animation performance angular material - angularjs

I have made a sidenav using angular-material's md-sidenav and below is the screenshot of it. When i try click on the button for sidenav the animations pretty lagging. I have used on an image on the top bar and the rest just text with font-awesome icons. What could i be possibly doing bad that it is slow. The animations are even worse when i view it on mobile.
Screenshot of sidenav :
Here is the code of sidenav :
<md-sidenav class="boxme-sidenav" layout="column" hide-gt-sm class="md-sidenav-left md-whiteframe-z2" md-component-id="left">
<div layout="coloumn" style="z-index:1000;box-shadow:2px 0px 10px grey;">
<div flex class="sidenav-logo">
<img ng-src="{{mainLogo}}" alt="">
</div>
</div>
<md-list style="background-color:#00B0FF;color:white;z-index:10;">
<md-list-item class="md-2-line sidenav-list" layout-padding>
<md-button href="" layout-align="space-around center">
<i class="fa fa-size fa-briefcase"></i>
<span class="md-body-2">Dashboard</span>
</md-button>
</md-list-item>
<md-list-item class="md-2-line sidenav-list" layout-padding layout-align="start center">
<md-button href="">
<i class="fa fa-size fa-user"></i>
<span>My Stuff</span>
</md-button>
</md-list-item>
<md-list-item class="md-2-line sidenav-list" layout-padding layout-align="start center">
<md-button href="">
<i class="fa fa-size fa-file-o"></i>
<span>Order History</span>
</md-button>
</md-list-item>
<md-list-item class="md-2-line sidenav-list" layout-padding layout-align="start center">
<md-button href="">
<i class="fa fa-size fa-credit-card"></i>
<span>Billing</span>
</md-button>
</md-list-item>
<md-divider></md-divider>
<md-subheader style="background-color:#00B0FF;color:white;">Manage the items</md-subheader><!--You can use md-no-sticky class-->
<md-list-item class="md-2-line sidenav-list" layout-padding layout-align="start center">
<md-button href=""><i class="fa fa-size fa-user"></i> Pickup my stuff</md-button>
</md-list-item>
<md-list-item class="md-2-line sidenav-list" layout-padding layout-align="start center">
<md-button href=""><i class="fa fa-size fa-user"></i> Deliver my stuff</md-button>
</md-list-item>
</md-list>
</md-sidenav>
Note :
After a while the performance and animations of sidenav get real lagging on the web.

It may not be right solution for your case, but disabling backdrop and adding 1 tweak made transition performance acceptable for me (even on phone)
.md-sidenav-backdrop {
opacity: 0 !important;
}
md-sidenav.md-closed-add,
md-sidenav.md-closed-remove {
-webkit-transition: all .4s cubic-bezier(0.25, .8, .25, 1) !important;
transition: all .4s cubic-bezier(0.25, .8, .25, 1) !important;
}

I decided to just remove the animation as follows:
I looked through the AngularMaterial CSS file and removed all references to animations. KA-BOOM!
/**
* fix md-sidenav lag by removing animation
**/
.md-sidenav-backdrop {
opacity: 0 !important;
}
md-sidenav.md-closed-add,
md-sidenav.md-closed-remove,
md-sidenav.md-closed-add.md-closed-add-active,
md-sidenav.md-closed-remove.md-closed-remove-active,
md-sidenav.md-locked-open-remove-active,
md-sidenav.md-closed.md-locked-open-add-active
{
-webkit-transition: none !important;
transition: none !important;
}
---- edit ----
Also update to the latest version of AngularMaterial there seems to be an overall improvement in v1.0.0-rc4 compared to prior releases.

Related

Horizontal navigation in sidenav Angular

Can you please tell me if it is possible to implement navigation as in the following example? Only with the Angular Material. Thank you.
http://plnkr.co/edit/Ksfo7fnSB0c4DH6egE3S?p=preview&preview
<body ng-controller="MainCtrl" layout="row">
<md-sidenav class="md-sidenav-left md-whiteframe-z2" md-component-id="left" md-is-locked-open="true">
<md-toolbar class="md-theme-light">
<h1 class="md-toolbar-tools">Sidenav Right</h1>
</md-toolbar>
<md-content ng-controller="RightCtrl" class="main-ctr md-padding">
<div ng-show="mainMenu" class="mainmenu"> <md-list>
<md-list-item>
<md-icon aria-label="home" class="material-icons"
style="">home
</md-icon>
<p class="md-body-2 side-nav-item">Home</p>
</md-list-item>
<md-list-item ng-click="nav('back')">
<md-icon aria-label="settings" class="material-icons">settings
</md-icon>
<p class="md-body-2 side-nav-item">Settings</p>
<md-button class="md-secondary md-icon-button" ng-click="nav('back')">
<md-icon aria-label="chevron_right" class="material-icons">chevron_right</md-icon>
</md-button>
</md-list-item>
</md-list>
</div>
<div ng-show="submenu" ng-class="{donotshow:donotshow, submenu: true}" >
<md-list>
<md-list-item ng-click="nav('main')">
<md-icon aria-label="chevron_left" class="material-icons"
ng-click="nav('main')">chevron_left
</md-icon>
<p class="md-body-2 side-nav-item">Back</p>
</md-list-item>
<md-list-item>
<md-icon aria-label="people" class="material-icons"
style="">people
</md-icon>
<p class="md-body-2 side-nav-item">My Profile</p>
</md-list-item>
<md-list-item>
<md-icon aria-label="people" class="material-icons"
style="">people
</md-icon>
<p class="md-body-2 side-nav-item">account</p>
</md-list-item>
</md-list>
</div>
</md-content>
</md-sidenav>
</body>
</html>
Perhaps there is a decent solution out of the box.
It should be possible to implement it by using stepper API.
https://material.angular.io/components/stepper/overview

Angular Material Design layout that wraps content

How to achieve the following layout (with "plus" icon below the card layout) ? :
I tried the following code :
<section layout="column" style="background-color: black;">
<md-card flex="100">
<md-card-header style="background-color: greenyellow; ">
<h2>Card headline</h2>
</md-card-header>
<md-card-content class="inline">
Card content
</md-card-content>
</md-card>
</section>
How's this?
<div class="demo" ng-app="MyApp">
<md-content class="md-padding" flex-gt-xs="50">
<div layout="column" layout-align="center center">
<md-card>
<md-card-title>
...
</md-card-title>
</md-card>
<md-button class="md-fab" aria-label="Eat cake">
<md-icon md-svg-src="img/icons/cake.svg"></md-icon>
</md-button>
</div>
</md-content>
</div>
Here's a Codepen modified from one of the original card examples.

Angular Material: Each md-list-item takes full page width and Sidenav have long scrollbar

I'm trying to create angular material sidenav with list of menu items. When Im running the code on local machine, Each md-list-items takes fullpage width and sidenav have long scroll bar.
But When I run the same code on codepen.io, It displayed correctly.
<section layout="row" ng-controller="AppCtrl">
<md-sidenav class="md-sidenav-left md-whiteframe-z2" md-component-id="left" >
<md-toolbar ng-controller="LeftCtrl">
<div class="md-toolbar-tools">
<h1>Sidenav Right</h1>
<span flex></span>
<md-button class="md-icon-bitton" aria-label="Close Menu" ng-click="close()">
<md-tooltip md-direction="right">Close this menu</md-tooltip>
<md-icon md-font-icon="material-icons">close</md-icon>
</md-button>
</div>
</md-toolbar>
<md-content flex role="navigation">
<md-list>
<md-list-item>
<md-button>First Option</md-button>
</md-list-item>
<md-list-item>
<md-button>First Option</md-button>
</md-list-item>
<md-list-item>
<md-button>First Option</md-button>
</md-list-item>
</md-list>
</md-content>
</md-sidenav>
<md-content flex>
<md-toolbar>
<div class="md-toolbar-tools">
<md-button class="md-icon-button" aria-label="Settings" ng-click="toggleLeft()" ng-hide="isOpenLeft()">
<md-icon md-font-icon="material-icons">menu</md-icon>
</md-button>
<h2>
<span>Application Title</span>
</h2>
</div>
</md-toolbar>
</md-content>
</section>
Here is the codepen:http://codepen.io/nhere/pen/yOwJxE
Try to use the following structure
<md-list>
<md-item>
<md-item-content>
[Content Here]
</md-item-content>
</md-item>
</md-list>

angular material right side bar issue

see this angular material demo at http://codepen.io/joyal/pen/mPpGBK
<div ng-controller="AppCtrl" layout="column" style="height:500px;" class="sidenavdemoBasicUsage" ng-app="MyApp">
<md-toolbar layout="column" class="main-toolbar md-medium-tall">
<span flex="flex">
<h1 class="md-toolbar-tools">Good luck overlapping me, sidenavs</h1>
</span>
</md-toolbar>
<section layout="row" flex="">
<md-sidenav class="md-sidenav-left md-whiteframe-z2" md-component-id="left" md-is-locked-open="$mdMedia('gt-md')">
<md-toolbar class="md-theme-indigo">
<h1 class="md-toolbar-tools">Sidenav Left</h1>
</md-toolbar>
<md-content layout-padding="" ng-controller="LeftCtrl">
<md-button ng-click="close()" class="md-primary" hide-gt-md="">
Close Sidenav Left
</md-button>
<p hide-md="" show-gt-md="">
This sidenav is locked open on your device. To go back to the default behavior, narrow your display.
</p>
</md-content>
</md-sidenav>
<md-content flex="" layout-padding="">
<div layout="column" layout-fill="" layout-align="top center">
<p>
The left sidenav will 'lock open' on a medium (>=960px wide) device.
</p>
<p>
The right sidenav will focus on a specific child element.
</p>
<div>
<md-button ng-click="toggleLeft()" class="md-primary" hide-gt-md="">
Toggle left
</md-button>
</div>
<div>
<md-button ng-click="toggleRight()" class="md-primary">
Toggle right
</md-button>
</div>
</div>
<div flex=""></div>
</md-content>
<div layout="row">
<!--This is new-->
<md-sidenav class="md-sidenav-right md-whiteframe-z2" md-component-id="right">
<md-toolbar class="md-theme-light">
<h1 class="md-toolbar-tools">Sidenav Right</h1>
</md-toolbar>
<md-content ng-controller="RightCtrl" layout-padding="">
<form>
<md-input-container>
<label for="testInput">Test input</label>
<input type="text" id="testInput" ng-model="data" md-sidenav-focus="">
</md-input-container>
</form>
<md-button ng-click="close()" class="md-primary">
Close Sidenav Right
</md-button>
</md-content>
</md-sidenav>
</div>
</section>
</div>
If you open the left side bar, it opens smoothly but if you open the right side bar, while opening and closing, a scroll bar appears on the page (horizontal scroll bar in the main content area).
How can I update the page so that right side bar opens and closes like left side bar (smoothly without scroll bar on content area)
You can use the overflow: hidden in your body, but it may effect to other component(s). Try this:
#sideNavContainer
{
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
}
Hope this help.

FAB Speed Dial and Simple dropdown menu not working

I've followed the demo as given in the angular material site.
https://material.angularjs.org/latest/#/demo/material.components.menu
I'm facing a problem where the simple dropdown menus and speed dials are just static and not initalized.
Can't seem to figure out what I am missing.
<div layout="column">
<md-content class="md-padding" layout="column">
<div class="lock-size" layout="row" layout-align="center center">
<md-fab-speed-dial md-open="false" md-direction="up"
ng-class="md-fling">
<md-fab-trigger>
<md-button aria-label="menu" class="md-fab md-warn">
<i class="fa fa-car"></i>
</md-button>
</md-fab-trigger>
<md-fab-actions>
<md-button aria-label="twitter" class="md-fab md-raised md-mini">
<i class="fa fa-car"></i>
</md-button>
<md-button aria-label="facebook" class="md-fab md-raised md-mini">
<i class="fa fa-car"></i>
</md-button>
<md-button aria-label="Google hangout" class="md-fab md-raised md-mini">
<i class="fa fa-car"></i>
</md-button>
</md-fab-actions>
</md-fab-speed-dial>
</div>
</md-content>
</div>
I changed the ng-class attribute on the <md-fab-speed-dial> tag to simply class, and it works now. Have a look at this link from the Angular Material site.
In your case, you should have:
<md-fab-speed-dial md-open="false" md-direction="up" class="md-fling">

Resources