We are using the Trade Theme (15.0) with a the Sticky Header - “Always Reduce Logo Size”
We want the sticky header to have some transparency when you scroll down, basically when it reduces the logo size on scroll down that it also adds some transparency to the header, so its not so in your face anymore.
We’re happy to see that our suggestion helped you solve the issue. Can you kindly give us a like and mark it as a solution? This can be a reference for other merchants if they have an issue like you.
I did some more trial and error and found this to work.
Question, I’m trying to get the padding to go from the normal 1.2rem to 1.0rem on scroll as well just to reduce the size of the sticky menu. When I adjust the above script it only adds the style tag to the first menu item. Is there a way to adjust all of the menu items with the header__menu_item class? Sorry its been a long time since i programmed, need to get back into it. Guessing i need to do an array or something?
Oh I like this, yeah the scrolling doesn’t matter. Its more that it happens at the same time as when the logo gets smaller when we scroll down.
Our header is a bit in your face for it to be there the whole time as a sticky header, IMO. Its for my daughters candle business so the header is Pink, but once you scroll down its too much for my liking. So wanted some transparency to soften it, and also now looking to change the menu padding top&bottom to make it a bit smaller.
I’ve got it working in JS but I like your method. Is there any way to transition/change the padding for the menu at the same time?
It’s great that you’ve found a way to make it work.
With your question, you need to identify if there are any commonalities among the menu items you’ve selected, such as matching the class name ‘header-wrapper-items’.
Then, you use var header-item = document.querySelectorAll(‘.header-wrapper-items’); which returns a NodeList.
Convert it to an array:
let myArray = Array.from(header-item). Then, map through myArray to access each item:
myArray.map((item, index) => {
item.style.height = ‘1rem’; // Assuming ‘height’ is the property you want to change
})
And you place this code snippet inside the event listener for the window scroll event.
Hope this can help you,
If our suggestions are useful, please let us know by giving it a like or marking it as a solution. Thank you