Hi,
URL: https://vinalisjak.si
the anchor links problem was indeed caused by JS custom code (no error notification in browser console). It was inserted to automatically close mobile navigation after user taps on menu and was suggested by Themeco developers few years ago. It worked great.
If I remove the code, the desktop navigation works without jQuery Migrate Helper, but the animation is much slower than before. Also the mobile menu does not automatically close after tap.
Would it be too much trouble for you to check/rewrite the code below so it works in Worpdress 5.6.?
Thank you.
//MOBILE NAVIGATION:
jQuery(document).ready(function($) {
var $body = $(‘body’);
var bodyHeight = $body.outerHeight();
var adminbarHeight = $(’#wpadminbar’).outerHeight();
var navbarFixedTopHeight = $(’.x-navbar’).outerHeight();
var locHref = location.href;
var locHashIndex = locHref.indexOf(’#’);
var locHash = locHref.substr(locHashIndex);
var dragging = false;
$body.on(‘touchmove’, function() {
dragging = true;
} );
$body.on(‘touchstart’, function() {
dragging = false;
} );
//
// Calculate the offset height for various elements and remove it from
// the element’s top offset so that fixed elements don’t cover it up.
//
function animateOffset( element, ms, easing ) {
$(‘html, body’).animate({
scrollTop: $(element).offset().top - adminbarHeight - navbarFixedTopHeight + 1
}, ms, easing);
return false;
}
//
// Page load offset (if necessary).
//
$(window).load(function() {
if ( locHashIndex !== -1 && $(locHash).length ) {
animateOffset(locHash, 1, ‘linear’);
}
});
//
// Scroll trigger.
//
$(‘a[href*="#"]’).off(‘touchend click’).on(‘touchend click’, function(e) {
console.log($(’.hm1.x-bar-fixed’).outerHeight());
href = $(this).attr(‘href’);
notComments = href.indexOf(’#comments’) === -1;
if ( href !== ‘#’ && notComments ) {
var theId = href.split(’#’).pop();
var $el = $(’#’ + theId);
if ( $el.length > 0 ) {
e.preventDefault();
if (dragging) {
return;
}
animateOffset($el, 850, 'xEaseInOutExpo');
if(!$('.x-nav-wrap-mobile').hasClass('.x-collapsed')) {
$('.x-btn-navbar').click();
}
return false;
}
}
});
});