Created
July 15, 2015 02:41
-
-
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
This file contains hidden or 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
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