Skip to content

Instantly share code, notes, and snippets.

@garrying
Created July 15, 2015 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garrying/13685f861c4da35877df to your computer and use it in GitHub Desktop.
Save garrying/13685f861c4da35877df to your computer and use it in GitHub Desktop.
Evaluate wrapping elements. Style first element in wrapped row on window.resize and dom.ready
docReady( function() {
var app = {
init: function () {
this._menuInit();
this._resizeEventListener();
},
_menuInit: function () {
var firstEle = [];
$('.menu-item').each(function(i){
$(this).removeClass('undotted');
var item = $(this).offset().top;
firstEle.push(item);
var itemFirst = firstEle.indexOf(item);
if (i === itemFirst) {
$('.menu-item').eq(i).addClass('undotted');
$(this).addClass(i);
}
});
},
_resizeEventListener: function() {
var resizeTimer;
$(window).on('resize', function(e) {
// Should probably debound this.
app._menuInit();
});
}
};
app.init();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment