Created
February 14, 2015 10:10
-
-
Save anonymous/a20cd2859e7cb57c9e5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @plugin name : Themesolve Nav. | |
** @plugin author : Muaz Hesam Musa. | |
** @release date : 1/12/2014; | |
*/ | |
;( function( window ) { | |
'use strict' | |
function orvilnav( el, options ) { | |
this.el = el; | |
this.options = extend( {}, this.options ); | |
extend( this.options, options ); | |
this._init(); | |
} | |
orvilnav.prototype.options ={}; | |
orvilnav.prototype._init = function(){ | |
//Nav wrapper | |
this.nav = this.el.querySelector('div.orvilnav'); | |
//main nav | |
this.main_nav = this.nav.querySelector('nav-menu'); | |
//manu item | |
this.menuItem = this.main_nav.querySelector('li a'); | |
//get top offset | |
this.getOffsetY = document.pageXOffset; | |
//get main menu height | |
this.menuHeight = this.nav.height; | |
//get main nav height | |
this.mainNavHeight = this.main_nav.height; | |
//get upper header height | |
this.upperHeadheight = (this.menuHeight - this.mainNavHeight); | |
//Initialing event | |
this._isScrolled(); | |
} | |
orvilnav.prototype._isScrolled = function(){ | |
var isScrolled = document.addEventlistener('scroll', function(){ | |
if( getOffsetY > upperHeadheight ){ | |
menuShrinks(); | |
} | |
else{ | |
menuNormal(); | |
} | |
}); | |
}; | |
orvilnav.prototype.menuShrinks = function(){ | |
this.menuItem.addClass('menu-shrinked'); | |
}; | |
orvilnav.prototype.menuNormal = function(){ | |
this.menuItem.removeClass('menu-shrinked'); | |
}; | |
//add to global namespace | |
window.orvilnav = orvilnav; | |
})( window ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment