What is the best way to enable momentum-based scrolling for the root <html> element in iOS Safari?

We are encountering difficulties in implementing momentum-based scrolling on iOS Safari for the root <html> element.

The following CSS snippet yields the desired outcome:


    html {
        height: 100%;
        overflow-y: scroll;
    }

    body {
        height: 100%;
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
    }
  

However, this causes the scrollbar to completely disappear.

We have tried the following approach to restore the scrollbar without success:


    ::-webkit-scrollbar {
        -webkit-appearance: none;
        width: 7px;
    }

    ::-webkit-scrollbar-thumb {
        border-radius: 4px;
        background-color: rgba(0,0,0,.5);
        -webkit-box-shadow: 0 0 1px rgba(255,255,255,.5);
    }
  

Furthermore, setting the body height using calc(100% + 1px) did not resolve the issue.

Even when half-way down the page, the JS snippet below outputs '0' as the scroll value:


    const y = document.body.scrollTop || 
    document.documentElement.scrollTop || 
    document.scrollingElement.scrollTop;

    console.log(y);
  

We acknowledge the buggy nature of momentum-based scrolling on iOS Safari.

  • Has anyone successfully enabled scrolling for the root <html> element?
  • Any suggestions on retrieving the scroll value document.body.scrollTop?

We are currently not considering the use of external libraries. Thank you.

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

How to effectively filter arrays using Angular.js

One array of objects that I have on hand looks like this: var arr = [{id:1, name: 'frank', type: 'great'}, {id:2, name: 'john', type: 'good'}, {id:3, name: 'mark', type: 'great'}, {id:4, name: &a ...

Tips for triggering an animation with button tap in Picker UI within Spark AR

After successfully following the Picker UI Patch tutorial to add buttons on my screen, I now want to incorporate animations into these buttons. Unsure of which Patches to include in my project, I have the animations listed in the Assets section for refer ...

Minimizing stationary header when scrolling down the page

I am working on a website that has a fixed header. The homepage displays additional content in the header when you are at the top of the page. However, I would like to hide this extra content and reduce the size of the header as users scroll down the page. ...

Arrangement of Divs Using CSS and HTML

Working on a New Website Hey there, I could really use some assistance in recreating the design shown in this image for my website project. I've made some progress but it's not quite coming together as expected. I'm struggling with positio ...

Is there a way to retrieve SQL information through an API and then incorporate that data into react-native-svg charts? I have an API that contains data I would like to retrieve and showcase

I am utilizing an API to retrieve data, which includes the execution of SQL queries. The API is responsible for fetching data and running these queries. I am looking for a way to replace the static data in my charts with dynamic data fetched from the API. ...

Tips for activating the button in Angular.js only when every checkbox is selected within a dynamically loaded display

In my AngularJS view, I have multiple checkboxes representing different terms of an agreement. <div class="modal-body"> <div class="col-xs-12 form-group"> <p>I acknowledge that I understand the following:</p> <div class= ...

Implement a JSON.parse fallback mechanism for an undefined array to prevent any potential exceptions

When parsing my array, everything works fine if it is defined: JSON.parse(myArray); However, I encounter an exception if myArray is undefined. What would be the best solution for this? Is there a more efficient alternative to this: JSON.parse(myArray | ...

What is the best way to create a responsive sticky toolbar that stays in place without any strange scrolling issues, even when the page is just a

I am trying to implement a code that moves a toolbar positioned below a header to stick to the top of the viewport while scrolling down. However, I am encountering an issue where if the content height exceeds the viewport height slightly and you try to scr ...

Having trouble with Jquery toggleclass function not functioning properly, despite closely replicating the example given

As a beginner in Jquery, I have some novice questions that I hope someone can help me with. I've been trying to implement code that toggles a class on and off when a user clicks a link. So far, I have managed to make it work so that clicking a link wi ...

Issue with serving Angular 2 index.html file from Express server due to path relativity problem

https://i.sstatic.net/PPcAA.png The structure of my app folder includes the angular-client folder https://i.sstatic.net/euEl5.png In the image below, you can see the problem I am facing. When serving the index file of the Angular app from an Express ser ...

What is the best way to eliminate the initial key from a JSON object

How can I remove the first index in a JSON object? JSON: {"data":[{"label":"Data","data":1},{"label":"Website","data":1}]} I need: [{"label":"Data","data":1},{"label":"Website","data":1}] When I try to delete .data, it outputs object{} JavaScript c ...

$q.all - successfully resolving some HTTP requests while encountering errors on others

I encountered a coding scenario like this angular.forEach(config.tvshows.shows, function(show) { promises.push($http.get('http://epguides.frecar.no/show/' + show.replace(/\s|\./g, '') + '/next/')); }); re ...

"What is the most accurate way to determine the actual height of a DIV

Exploring the HTML structure I have: <div id="container"> <h1>This is an h1 element</h1> </div> Upon attempting to determine the height of the container in Firefox or Chrome using JavaScript: var container = document.getElem ...

Incorporating Sass into Django

As I delve into my Django Project, one question looms large: where exactly should all my Sass files be placed? Is it more practical to create a central 'Sass' folder within the main Project Folder or designate a 'Sass' directory for eac ...

Ways to prevent body content from overlapping with footer content and appearing below

Currently, I am utilizing an autocomplete text box where the scroll bar exceeds based on dynamic values. However, if more values are displayed in the text box, the scroll bar automatically extends to exceed the footer of the page, resulting in two scroll b ...

Include the array in the 'content' property of the CSS using Jquery

I need help formatting data in CSS. The code I have is as follows: if (ext){ switch (ext.toLowerCase()) { case 'doc': pos = 'doc'; break; case 'bmp': pos = 'bmp'; break; ...

The special $ character in angularjs does not seem to be effective in filtering by object

Angularjs documentation states that the filter method should be able to accept an object as a parameter. This object allows you to specify the column to filter by, or use the special character "$" to search through all properties. While the filter works ...

Ways to have the right sidebar seamlessly blend in with the page content by hovering over it rather than occupying a separate area

While working on the design of my website, I encountered a challenge with the sidebar. I aim to have a sidebar that hovers from the right side to the left, displaying the full content when the cursor is placed over it, much like the one featured on . Altho ...

Authentication in Feathers JS without the need for email addresses

Currently, I am in need of an authentication system for my dApp that operates without using email addresses or storing any user information. What I require is an endpoint where users can submit a seed phrase and password to generate a JWT. The process shou ...

Transform JSON data into a string separated by commas with an array embedded within

I've been trying to work with a JSON data but can't seem to convert it as needed. Here is the JSON structure: {"domiciles":[{"country":"AF"},{"country":"AX"},{"country":"AL"}],"investor":[{"type":"ii"},{"type":"pi"}]} It's stored in sessio ...