How to make the entire upper menu stay in focus?

Allon Prooit Posted in Performance and Scalability 3 years ago

I am trying to get the entire upper mobile menu to remain in focus. Does anyone know where the code is located for this? I imagine I have to change it from relative to absolute or sticky somewhere. See picture for which menu I'm referring to...
enter image description here

Replies
us Allon Prooit Replied 3 years ago

Made a small component in response to this query. TopbarFocusizer!

us Allon Prooit Replied 3 years ago

Many thanks for your kind thoughts Z man! I will look into the how-to pages more now. I hadn't really thought to use them much. Was hoping that this innovation would be like the privacy changer and that y'all would run with it and hopefully make it a standard feature for OSSN. Will see if I can get it to work and perhaps introduce it as a component. If not, I will put my findings here.

German Michael Zülsdorff Replied 3 years ago

Thoughts? For sure yes.
Why, for example, not much more use is made of the how-to pages on this forum. There's the https://www.opensource-socialnetwork.org/wiki/view/1137/how-to-find-something-a-word-pattern-in-the-source-code page, which shows how to find page elements, and there's the https://www.opensource-socialnetwork.org/component/view/167/hello-world component, which explains how and where to add javascript. Is that just asking too much to look at these guides, or are the explanations just awful?

us Allon Prooit Replied 3 years ago

Ok so I found some Javascript code that may work to make the upper menu disappear when you scroll down but then reappear the moment you scroll up. The only question is, where do I put it? Here it is... (pretty sure you have to change navbar to topbar)

/* When the user scrolls down, hide the navbar. When the user scrolls up, show the navbar */
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("navbar").style.top = "0";
} else {
document.getElementById("navbar").style.top = "-50px";
}
prevScrollpos = currentScrollPos;
}

Also, you have to edit the themes default css for the topbar to make this work. You'll have to add the following...
to .topbar
position: fixed; /* Make it stick/fixed /
top: 0; /
Stay on top /
width: 100%; /
Full width /
transition: top 0.3s; /
Transition effect when sliding down (and up) */

Any thoughts?

us Allon Prooit Replied 3 years ago

I would hope that someone in the Community knows the answer to this. I've answered plenty of questions here. I've got little money for a CSS developer at this time. Thanks though!

Indonesian Arsalan Shah Replied 3 years ago

You need to consult a css developer for this as mentioned in my initial reply it requires many changes to fit the fixed condition.

us Allon Prooit Replied 3 years ago

Got the menu to stay focused but lost the SEARCH button functionality for mobile users. Needing help there. Also, had to change the top bar logo image to 0px height to get it to go away. Any thoughts on how to get the top bar logo image to collapse upwardly or maybe have the entire menu collapse upwardly as well?

us Allon Prooit Replied 3 years ago

Ok, so change the setting to fixed. I've found the code for the leftwise menu and the search function. Now just needing to find the rest of the code. Where is it?

Indonesian Arsalan Shah Replied 3 years ago

You need to change to position fixed with more changes in css other than fixed to adjust pages.