jquery(document).ready(function($){ var ww = $(document).width(); $(".s1 video").width(ww); var overlaynav = $('.cd-overlay-nav'), overlaycontent = $('.cd-overlay-content'), navigation = $('.cd-primary-nav'), togglenav = $('.cd-nav-trigger'); //inizialize navigation and content layers layerinit(); $(window).on('resize', function(){ window.requestanimationframe(layerinit); }); //open/close the menu and cover layers togglenav.on('click', function(){ if(!togglenav.hasclass('close-nav')) { //it means navigation is not visible yet - open it and animate navigation layer togglenav.addclass('close-nav'); overlaynav.children('span').velocity({ translatez: 0, scalex: 1, scaley: 1, }, 500, 'easeincubic', function(){ navigation.addclass('fade-in'); }); } else { //navigation is open - close it and remove navigation layer togglenav.removeclass('close-nav'); overlaycontent.children('span').velocity({ translatez: 0, scalex: 1, scaley: 1, }, 500, 'easeincubic', function(){ navigation.removeclass('fade-in'); overlaynav.children('span').velocity({ translatez: 0, scalex: 0, scaley: 0, }, 0); overlaycontent.addclass('is-hidden').one('webkittransitionend otransitionend otransitionend mstransitionend transitionend', function(){ overlaycontent.children('span').velocity({ translatez: 0, scalex: 0, scaley: 0, }, 0, function(){overlaycontent.removeclass('is-hidden')}); }); if($('html').hasclass('no-csstransitions')) { overlaycontent.children('span').velocity({ translatez: 0, scalex: 0, scaley: 0, }, 0, function(){overlaycontent.removeclass('is-hidden')}); } }); } }); function layerinit(){ var diametervalue = (math.sqrt( math.pow($(window).height(), 2) + math.pow($(window).width(), 2))*2); overlaynav.children('span').velocity({ scalex: 0, scaley: 0, translatez: 0, }, 50).velocity({ height : diametervalue+'px', width : diametervalue+'px', top : -(diametervalue/2)+'px', left : -(diametervalue/2)+'px', }, 0); overlaycontent.children('span').velocity({ scalex: 0, scaley: 0, translatez: 0, }, 50).velocity({ height : diametervalue+'px', width : diametervalue+'px', top : -(diametervalue/2)+'px', left : -(diametervalue/2)+'px', }, 0); } });