I am trying to implement a custom logo on a website, but I am doing something wrong and cannot find the error. Maybe you can give a little advice.
So what I have already done:
1.Child theme with style.css, functions.php, assets / js / my_shrinker.js
2. I added a function to load my-shrinker.js in functions.php
function shrinker() {
wp_enqueue_script( 'my_shrinker', get_stylesheet_directory_uri().'/assets/js/my_shrinker.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'shrinker' );
3.Remove this code to perform scroll compression in my-shrinker.js
function my_shrinker() {
window.addEventListener('scroll', function(event){
var distanceY = window.pageYOffset || document.documentElement.scrollTop,
shrinkOn = 300,
d = document.getElementsByTagName("kad-header-left");
if (distanceY > shrinkOn) {
d.className += " shrinkedlogoyo";
} else {
d.classList.remove("shrinkedlogoyo");
}
})
}
the script should add the "shrinkedlogo" class to the kad-header-left div div that this css has
.shrinkedlogoyo { display: block !important; position: absolute !important; left: 8% !important; top: 2px !important; width: 45px !important; height: 45px !important; }
But, this does not happen, and I do not get any errors. Can you give me some good advice?
Website http://arthome17.ru