I'm getting this error message:
Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
and this second line of code is being flagged
var nav = document.querySelector('.navv'),
nav_height = getComputedStyle(nav).height.split('px')[0],
I'm in the middle of converting a static webpage into a Ruby on Rails app and this code works just fine on the original project, but I'm getting this error message on Rails. How do I get this code working again?
Here is the rest of the function for refrence:
var nav = document.querySelector('.navv'),
nav_height = getComputedStyle(nav).height.split('px')[0],
nav_links = document.querySelector('.nav-links'),
//nav_links_height = getComputedStyle(nav_links).height.split('px')[0],
sticky_class = 'is-fixed';
//unfixed = 'unfixed'
function stickyScroll(e) {
if( window.pageYOffset > (nav_height) ) {
nav_links.classList.add(sticky_class);
}
if( window.pageYOffset < (nav_height) ) {
nav_links.classList.remove(sticky_class);
}
}