I'm experimenting using Zepto animate and CSS3 transitions for animating a div to the left and back again on button click. For this I'm using toggleClass which adds and removes a class with styling of margin-right:-0;
All is working but I'm experiencing a very slight delay on mobile devices when clicking the button to toggle the class. I've got it working using animate with no delay but CSS3 transitions are hardware accelerated so I was hoping to make the animation slightly smoother.
Essentially when I click the button to toggle the animation there is a very slight pause before it fires, I want to get rid of this.
Code is below, anyone got any ideas why I'm getting this slight delay? My guess would be that it's to do with how quickly a class can be toggled and its styling read?
Any help/insight is appreciated!
#side-menu {
float: right;
height: 100%;
width: 80%;
overflow: scroll;
margin-right:-1024px;
box-shadow: 4px 0 5px #484848 inset;
-webkit-box-shadow: 4px 0 5px #484848 inset;
-moz-box-shadow: 4px 0 5px #484848 inset;
background: linear-gradient(#444444, #333333) repeat scroll 0 0 #595858;
background: -webkit-linear-gradient(#444444, #333333) repeat scroll 0 0 #595858;
background: -moz-linear-gradient(#444444, #333333) repeat scroll 0 0 #595858;
background: -o-linear-gradient(#444444, #333333) repeat scroll 0 0 #595858;
-webkit-transition: margin-right 1s ease-in-out;
-webkit-transform: translate3d(0, 0, 0);
-webkit-transform: translateZ(0);
}
.sideMenuToggle{margin-right: 0 !important;}
$('#menu_toggle').on('click', function(){
$('#side-menu').toggleClass('sideMenuToggle');
})