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

Is incorporating RequireJS into an AngularJS project a valuable decision?

Is it true that AngularJS has its own module loading mechanism built-in and using RequireJS is unnecessary or even inefficient? I am working on an Angular project where the index.html file is becoming quite large. Would incorporating RequireJS help reduc ...

Stop Caching with Jquery Infinite Scroll (IAS)

I am using jQuery + IAS to implement infinite scroll functionality on my website. However, I have encountered an issue where the cache is being disabled when making requests for new content. Specifically, the URL that is accessed to retrieve the next page ...

How to Build a Number Spinner Using Angular Material?

Is there a number spinner in Angular Material? I attempted to use the code provided in this question's demo: <mat-form-field> <input type="number" class="form-control" matInput name="valu ...

Tips for enabling the OnLoad Event for a React Widget

Hey there! I'm a beginner with React and I'm struggling to call a function once after the component is created. I tried adding an onLoad event in the component creation, but it's not working as expected. The function 'handleClick' ...

Displaying information post-inquiry - Google Visualizations

I have a data-table using Google chart and I am looking to establish a connection with the table by sending a URL query. Once the query is sent, I want to display the retrieved data on my web page using JavaScript. How can I achieve this? Below is the cod ...

POST request body is not defined

Client Interface: procedure OnButtonClick(Sender: TObject); begin gcm := GetGCMInstance; p := TJavaObjectArray<JString>.Create(1); p.Items[0] := StringToJString('460004329921'); FRegistrationID := JStringToString(gcm.register(p)); ...

Vue.js Enhances CoolLightBox with Multiple Galleries

I am trying to set up a page with multiple galleries using CoolLightBox. It worked fine for me when I had just one gallery, but now that I want to create multiple galleries - each with its own image on the page - it is only displaying one image in the ligh ...

How can you make the contents of a <DIV> expand?

Picture a scenario where I have a navigation bar in the header of my web page, consisting of several links. What I want is for these links to expand horizontally to fill the parent container without me having to hard-code based on the number of links. In o ...

Easily validate the contenteditable attribute of <td> element

I am currently working on a table that displays data from a MYSQL database. Whenever a user makes changes to an element in the table, I want the database to be updated using AJAX. Below is my JavaScript code for sending data in an editable row. function s ...

Disabling the scrollbar in Selenium screenshots

When using Chromedriver to capture screenshots of webpages, my code effectively does the job. However, I am now facing an issue with removing the unsightly scrollbars from the image. Is it feasible to inject CSS into the webpage in order to achieve this? W ...

Send your information to a JSONP endpoint

Can data be posted to JsonP instead of passing it in the querystring as a GET request? I have a large amount of data that needs to be sent to a cross-domain service, and sending it via the querystring is not feasible due to its size. What other alternati ...

Looking for guidance on implementing a Live Search feature using jQuery, AJAX, JSP/Servlet, MySQL, and JSON?

After conducting research, I have received varied responses regarding this topic. The table contains 2,000 records and is updated monthly with only a small number of new entries (5-10). The structure of the table is simple: id, name, data1, data2, data3 ...

Utilize jQuery selectors to target elements on a web page that has been stored in a variable

Currently, I am in the process of developing a Greasemonkey script that involves using JQuery. As part of this project, I am loading multiple pages into variables and successfully retrieving them using $.get. One challenge I have encountered is figuring o ...

Sharing data across multiple paths

route.post('/register',function(req,res){ //completed registration process // token value assigned as 'abc' }) route.post('/verify',function(req,res){ // How can I retrieve the token ('abc') here? }) I' ...

Determine the number of properties present in two arrays by comparing them

Looking to compare two arrays and determine the count of items in the master list. A sample master list could be: { name: 'Emily', age: 29 }, { name: 'Jack', age: 31 }, { name: 'Lily', age: 28 }, { name: 'Emily', a ...

Limit the input to a specific format

Currently developing a JavaScript application, but having some confusion with Regular Expressions. The main goal is to allow users to input a specific format of strings in a text area for the application to process accordingly, thus requiring restriction o ...

Having trouble retrieving information from the server using ajax, javascript, jquery, and php

I am currently facing an issue with sending data retrieved from a jQuery call and attempting to save it to a server file using PHP. function getSVG(){ svghead = svghead + $('#test').html(); $.ajax({ type:"POST", da ...

How to Enhance HTML Requests with a Variety of Search Terms

I recently came across a helpful post on how to use R to search for news articles on Google. The post provides a link to Scraping Google News with Rvest for Keywords. The example in the post demonstrates searching for a single term, such as: keyword <- ...

Troubleshooting issue with CSS SVG Clip path functionality - facing technical difficulties

Having an issue with a clip path in my CSS. When I apply the clip path to my CSS fill, the image isn't showing up... I'm using Chrome. Any ideas on how to fix this? I found this helpful generator https://example.com .card .content .picture img { ...

Issue with Express - Session not persisting across consecutive SSE requests

Currently, I am delving into Server-sent Events using Node.js and Express. I have successfully set up request handling and stream writing, but I am facing challenges with session management. The session does not persist between subsequent calls. Snippet o ...