Uncaught TypeError: Cannot read properties of undefined (reading ‘getBoundingClientRect’)
at isElementInViewport ((index):1082:31)
at checkFooterVisibility ((index):1122:22)
This function is throwing an error in my website. How could I fix it? It’s located at this function:
// utility function to check if an element is in viewport
function isElementInViewport(el) {
var rect = el.getBoundingClientRect();
// var header_menu_affix = jQuery('.td-header-menu-wrap.td-affix'),
// header_menu_affix_height = header_menu_affix.length ? header_menu_affix.outerHeight() : 0;
// var admin_bar = jQuery('#wpadminbar'),
// admin_bar_height = admin_bar.length ? admin_bar.outerHeight() : 0;
// var setTop = tdFooterWrap.offset().top/* - ( header_menu_affix_height + admin_bar_height )*/,
// setHeight = tdFooterWrap.outerHeight(true),
// setBottom = setTop + setHeight; // set the bottom by adding its height to the scroll position of its top
// var win = jQuery(window),
// windowTop = win.scrollTop(),
// windowBottom = windowTop + win.height();
/* rest */
// console.log( 'rect', rect );
// console.log( 'rect:top', rect.top );
// console.log( 'rect:bottom', rect.bottom );
// console.log( 'window.innerHeight', window.innerHeight );
/* element */
// console.log( 'top', setTop );
// console.log( 'height', setHeight );
// console.log( 'bottom', setBottom );
/* window */
// console.log( 'window top', windowTop );
// console.log( 'window bottom', windowBottom );
return (rect.bottom >= 0 && rect.top <= (window.innerHeight || document.documentElement.clientHeight));
}
Hi,
From what I can see, this error might be caused by incorrect configuration of the theme and plugins. What I can suggest is to have a clean install of WordPress, do a clean install of the theme, make sure everything is up to date, and not have other extra plugins active. Use the main theme, not a child theme, and ensure the PHP version is 8.0 or 8.1.
Thank you!