Showing no background color until the user lifts their finger

I am currently in the process of developing a website. The navigation on the website starts off as transparent (background: transparent) when opened, but as soon as you start scrolling, it should transition to a colorful state with shades like grey, midnight blue, or similar colors. At the bottom of the page, there is a div which, upon scrolling all the way down, the navigation disappears using display:none. However, if you scroll back up slightly, it should reappear with display:block. This functionality seems to work well, except for a minor issue experienced specifically on iPad (although not tested on other touchscreen devices).

The problem arises when I scroll down to the bottom of the page and then attempt to scroll back up. In this scenario, the navigation bar does reappear, but without retaining its background-color until I release my finger from the screen. Quite strange, isn't it?

I hope these descriptions make sense. For visual representation, please refer to the following images:

https://i.stack.imgur.com/M2cD1.png

While scrolling back up, the navigation bar should have a defined background-color, yet while holding onto the screen, it remains transparent as depicted.

https://i.stack.imgur.com/evfFv.png

Upon reaching the bottom of the page, the menu successfully disappears, which is the expected behavior.

https://i.stack.imgur.com/s3PmM.png

This situation should occur when scrolling upwards enough; however, it fails to function correctly if continuous scrolling (holding) is ongoing.

For further details, view the JSFiddle demo... The CSS content exceeds 1500 lines, where an essential snippet is

#main-header {
    position: fixed;
    width:100%;
    height:70px;
    top:0;
    background-color:#34495e;
    z-index: 100;
}

https://jsfiddle.net/0vL1dpas/ <- Visit JS fiddle for demonstration NOTE Complexity due to extensive code and JS focus!

Don't forget to check out the operational website:

A secondary note to mention

$(function(){
  $(window).on('load scroll resize orientationchange', function () {
      var my_height = $("#full_contact").height();
      var important = $(document).height();
      var final = important - my_height;
    if ($(window).scrollTop() < final) { 
        $('#main-header').css("display", "block");
        $('#main-header').css("background-color", "#34495e");
        document.getElementById("#navigace");
        $('#navigace').addClass('.navigace_scroll');
        $('.navigace_scroll').removeClass('#navigace');

    }
    else{
        $('#main-header').css("display", "none");
    }
  });
});

This script represents the core mechanism behind the disappearing navigation at the bottom feature.

To sum it up succinctly, my primary query is...

"Why does the navigation appear with display:block;, but without the background color until I release my finger?"

Your prompt assistance in resolving this matter would be greatly appreciated as I am urgently seeking a solution.

Please feel free to provide any suggestions or guidance.

Thank you very much!

Answer №1

Take a look at this article. I encountered a similar problem with a scrollToTop button. It dawned on me that iOS exhibits peculiar behavior when it comes to triggering scroll events and executing JavaScript while scrolling (though this may not be your specific scenario). Hopefully, this information sheds some light on the issue.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Mastering the use of useMasterKey in Parse with Node.js: A guide

Greetings everyone, I have developed my app using parse.com but now I need to utilize the master key as some users have administrative roles. Initially, I attempted to use the JS SDK but was advised to switch to Cloud Code. So, I tried using Express and ...

What is preventing this jQuery from altering the opacity?

Currently, I have a piece of code that is intended to change the opacity of a div element from 0 to 1 as soon as the user initiates scrolling on the body. However, it appears to be malfunctioning for reasons unknown. $("bod").load(function(){ document ...

There seems to be an issue with the functionality of the JavaScript Quiz as it is

While working on my JS quiz, I encountered an issue where some answers were not displaying due to quotes and the need to escape HTML characters. Additionally, I am facing difficulty in accurately awarding points or deductions based on user responses. Curre ...

Tips for hiding a div element until its visibility is toggled:- Set the display property of

Looking for some guidance on this jQuery code I'm working with to create a toggle menu. The goal is to have the menu hidden when the page loads, and then revealed when a button is clicked. However, currently the menu starts off being visible instead o ...

What steps can be followed to incorporate a loading gif into this popup and subsequently eliminate it?

These simple inquiries are starting to get on my nerves. I can't keep waiting around for my website designer to resolve this issue. It shouldn't be that difficult... I managed to figure out most of it by researching similar questions, but I could ...

Align list items in the center horizontally regardless of the width

I have created this container element: export const Container = styled.section<ContainerProps>` display: flex; justify-content: center; `; The current setup is vertically centering three list items within the container. However, I am now looking ...

Arrange the HTML DOM elements in the order of their appearance in a list

Is it possible to rearrange the order of <div> and its elements based on database information? For example, consider the following HTML structure: <div id="container"> <div id="A"> Form elements for A</div> <div id="B"& ...

When I remove a user as admin, I am unable to retrieve all users to update the data table

I am currently working on an Admin Dashboard that includes a section for users. This section features a simple table displaying all the users in the MongoDB database along with some information. Additionally, there are functionalities to add a new user and ...

The tilesloaded event in google.maps.event.addListener is unexpectedly failing to trigger

Today, while testing popover messages on my cordova/ionic app, I compiled the app and noticed that the maps weren't loading. Instead, only my custom "Loading map..." spinning icon kept showing. Upon investigating further, I found that var setMap = n ...

Creating a responsive layout in HTML/CSS where the div element expands to fill the entire vertical space of its parent

Looking for assistance in creating a webpage layout like the one shown in this fiddle... http://jsfiddle.net/jeljeljel/5BSva/ I need the vertical line on the left side navigation tab to extend all the way down to the footer at the bottom of the page. Th ...

Node.js: The object in req is not functioning as expected

// Function to merge objects with unsent columns kept from old objects. function merge_options(obj1, obj2) { const obj3 = {}; for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; } for (var attrname in obj2) { obj3[attrname] = obj2[attrname] ...

What is the best method for interpreting XML using JavaScript?

I am facing a challenge with fetching and parsing an XML file using JavaScript. The XML-file is beyond my control. Recently, there has been a change in the encoding of some XML files which prevents the code from being parsed successfully. Previously it wa ...

How to position a "figure" element at the center using CSS creatively (without relying on Div elements)

Struggling with my first website creation, I encountered a challenge in centering three inline-block images using CSS. Despite successfully using the figure tag to title and display the images, I couldn't get them to align horizontally from the cente ...

"Engage with an Angular directive using a button positioned in any location on the

There is a directive implemented on my webpage with an assigned id attribute, regardless of its functionality. Now, I need a second directive that essentially triggers the first one. Here is an example of what I aim to achieve: <body> <!-- v ...

Is there a way to extract a specific element from an array stored within a form element's value?

I am encountering an issue with retrieving values from an array in an HTML form element using jQuery. Despite my efforts to explain and provide code, I am not getting the desired results. Can someone help me understand what is going wrong in my code? Thank ...

What are some ways to modify a Vue template without the need to recompile?

Is it feasible to modify a Vue template's HTML without the necessity of recompiling the Vue file? ...

Incorporate a unique element onto your WordPress homepage

I'm seeking guidance on how to incorporate a custom feature (including a textbox and a button) onto my WordPress homepage. My goal is to create an area where users can input a code into a textbox. Here's the challenging part: Once the user click ...

Tips for preventing a NodeJS script from crashing due to timeout being exceeded

Here is the issue I am encountering: I am attempting to scrape a website's content using NodeJS and puppeteer. Sometimes, my code halts with a Timeout Exceeded error. Is there a way for me to handle this timeout by implementing a function that will e ...

Scrolling to top using jQuery - Problem with incorrect anchor

I am attempting to implement a scrollTop animation that scrolls to an anchor within a fullscreen <section>. However, the issue is that it does not scroll to the correct anchor on the first click. Below is the code snippet. <nav id="scroller"> ...

Is there a way for me to automatically go back to the home page when I press the back button on the browser?

My ecommerce website has a shopping cart page where customers can purchase products and make payments. After the payment is completed, they are directed to a thank you page. The flow of the website is as follows: Home page => Products => Shopping ca ...