Skip to content

Instantly share code, notes, and snippets.

@RanMetser
RanMetser / pojomenufix.js
Created December 30, 2016 10:31
Fix Pojo menu active mode for a one page menu
jQuery(document).ready(function(jQuery) {
var topMenu = jQuery("#menu-main"),
// change offset manually as needed (usually menu height)
offset = 120,
topMenuHeight = topMenu.outerHeight()+offset,
menuItems = topMenu.find('a[href*="#"]'),
// Anchors corresponding to menu items
scrollItems = menuItems.map(function(){
var href = jQuery(this).attr("href"),
id = href.substring(href.indexOf('#')),