Tips for integrating scroll-snap and jQuery's .scroll() function together

I'm facing challenges in integrating both of these elements into the same project.

When I activate overflow: scroll, my jQuery function does not work as expected. However, if I deactivate it, then the jQuery works but the scroll-snap feature does not.

I attempted to modify the jQuery code from using "window" to "#scroll-parent" with the .scroll() method, but it did not yield any results.

$(window).scroll(function() {
  setMenuColor();
 });
body {
  font-family: "Montserrat";
  background: #000;
  margin: 0px;
  overflow-x: hidden;
}
#scroll-parent {
  //overflow: scroll;
  height: 100vh;
  scroll-snap-type: mandatory;
  scroll-snap-points-y: repeat(100vh);
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Answer №1

Incorrect placement of the #scroll-parent DIV within the HTML structure

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

Element numbering in Internet Explorer 9 now positioned towards the right bottom corner

Whenever I reload the page, the numbering in the li elements seems to shift towards the bottom-right only in IE9, while it displays correctly on other browsers like Firefox and Chrome. Should I implement a specific fix for IE or have I made an error in my ...

What is causing the Jquery repeater to not trigger .keyup and .change events on items beyond the second one?

I noticed that the .keyup and .change events are only triggered in the first input field and not after I add a new item. Is there a way to make these events trigger when adding a new field? http://jsfiddle.net/q8pcoaxf/ $('.field').on(& ...

Making a XMLHttpRequest/ajax request to set the Content-Type header

In my attempts, I have tested the following methods individually: Please note: The variable "url" contains an HTTPS URL and "jsonString" contains a valid JSON string. var request = new XMLHttpRequest(); try{ request.open("POST", url); request.set ...

There seems to be a glitch in my programming that is preventing it

Can someone please help me troubleshoot this code? I'm unable to figure out what's going wrong. The concept is to take user input, assign it to a variable, and then display a string. However, nothing appears on the screen after entering a name. ...

Is it possible to save a JavaScript interval in a jQuery element's data property?

In the process of developing a jQuery plugin, specifically a jQuery UI widget known as Smooth Div Scroll, I encountered an issue where I needed to store references to intervals that were unique to each instance of the plugin on a page. If I simply declared ...

Applying the jqtransform plugin to all forms except for one

We've implemented the jQuery jqtransform plugin to enhance the appearance of our website's forms. However, there is one particular form that we'd like to exclude from this transformation. I made adjustments to the script that applies jqtrans ...

Creating a persistent hover effect

Utilizing primarily CSS, along with background images and adjacent selectors, I am creating a page that displays unique human-readable text information when the user hovers over horizontally stacked images. The textual information is presented in a div on ...

Failed to fetch JSON file using jQuery

When I call a web service, I receive a JSON file. I am attempting to retrieve the data using jQuery and display it on an HTML5 page. When I open the JSON file in a browser at SampleURI, I do get the data. {"employeeList":[{"birthDate":"1948-12-08T00:00:00 ...

The header section on a website not behaving as expected in the Chrome browser

For my website, I want it to look like this in Internet Explorer: https://i.stack.imgur.com/hSkVM.png ^^ This is the IE view However, in Chrome, it displays like this: https://i.stack.imgur.com/noQw8.png The issue is with the Top bar on Chrome showing co ...

Centered on the page vertically, two distinct sentences gracefully align without overlapping, effortlessly adjusting to different screen sizes

I had no trouble centering horizontally but I'm struggling with vertical alignment. I want these two sentences to be positioned in the middle of the page, regardless of device size. I attempted using vertical-align without success and then tried posit ...

i am trying to execute a function in an angularjs controller through html, but the scope variable that i am

Being new to angularjs, I'm looking to understand the process of calling a function defined in a controller from HTML within angularjs. I have written the following code in my HTML: First.html <input type="text" ng-model="model.name" name="name ...

Boost the delay in the transition speed for hiding the Navbar while scrolling down with the help of Bootstrap

Hi there! I am currently learning HTML, CSS, and JS. I'm working on a homepage project using Bootstrap-5 and have successfully integrated a navbar. However, I've noticed that the navbar disappears too quickly when I scroll down. Is there a way to ...

Incorporating a download link with the combination of canvg and amcharts

I am attempting to include a download link on a page that utilizes AmCharts and CanVG. The visualization of the graph and image is functioning properly. Now, I am in need of a download link to offer users the ability to download the displayed graph image. ...

When AJAX is invoked, the HTML content fails to display within a div

The following is the ajax script I am currently utilizing: mypage.php $(".sales_anchor").click(function(e) { e.preventDefault(); var store_username = $("#storeUsername").val(); var store_id = $("#storeID").val(); var sale_id = $(this).a ...

Utilizing jQuery/Ajax to send an ID parameter to a PHP script

This code is where the user interacts. <html> <head> <title></title> <script src="jquery-1.9.1.js"></script> <script src="jquery.form.js"></script> </head> <body> <?php include 'con ...

Instead of logging the JSON file in the console, download it using $.getJson()

Is there a method to download a json file without using jQuery's $.getJSON() and having to log the callback function's argument? I would like to avoid manually typing it from the console.log due to its length. Is there an option to print it, eve ...

Navigating the "this" keyword within designated functions

Let's discuss a simple, yet interesting problem together: function return_this_normal(){ // console.log($(this)); $(this).css('color','green'); } $('.normal').mouseover( function(){ // console.log($(this ...

jQuery functions as expected in a test environment, but encounters issues when implemented on a live website

Recently, I implemented a piece of code that enables content to be copied from one div to another when a button is clicked: <a id="btn123">CLICK ME</a> <div id="test1"></div> <div id="test2"> <h1>Heading</h1> < ...

The alignment of the submit button is consistently off when placed alongside two input boxes within a table

Completing this task is usually straightforward. I have a sign-in form with an email input, password input, and submit button aligned horizontally. However, after trying various styles and structures for hours, the button appears slightly lower than the in ...

Unable to retrieve information using ajax in a codeigniter framework

I'm trying to display the restaurant information after selecting its area from a dropdown list. However, my code is not showing the restaurant name and the menu button for that restaurant. Can you please point out where I made a mistake? This is my m ...