1// Sticky element for navs 2// 3// -------------------------------------------------- 4function navStickyElement() { 5 6 // Define jQuery (Wordpress uses no conflict) 7 var $ = jQuery; 8 9 var $window = $(window), 10 $body = $('body'), 11 $target = $('.js-sticky-nav'), 12 media_list = matchMedia(helpers().screen_width.sm), 13 14 // State classes 15 state = { 16 sticky: 's-sticky-nav' 17 }; 18 19 $target.each(function (){ 20 21 var $el = $(this), 22 el_pos = $el.offset().top; 23 24 $window.on('scroll resize', function() { 25 26 if(media_list.matches == true) { 27 28 var window_pos = $window.scrollTop(); 29 30 // If the window has passed the position of the element 31 if(window_pos > el_pos) { 32 33 $body.addClass(state.sticky); 34 35 } else { 36 if($body.hasClass(state.sticky)) { 37 $body.removeClass(state.sticky); 38 } 39 } 40 } 41 }); 42 }); 43} 44 45jQuery(document).ready( function() { 46 47 var $ = jQuery; 48 49 // Update positions 50 helpers().debounceEvent($(window), 'resize', navStickyElement, 100); 51 52 navStickyElement(); 53 54});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.