Preventing the user from using the mouse wheel until the CSS animation finishes

I am working with multiple functions that are triggered by scrolling the mouse wheel up and down. These functions must be called in a specific order, but the issue arises when users scroll quickly causing the CSS animations from the previous function to not fully complete before the next function is called. How can I ensure that all CSS animations from the previous functions finish before allowing the user to continue scrolling?

Answer №1

If you want to temporarily disable scrolling on a webpage, you can achieve it by following these steps:

$('html, body').css({
    'overflow': 'hidden',
    'height': '100%'
});

$(".element").on('transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd', function() {
    // Revert back to original state
    $('html, body').css({
        'overflow': 'auto',
        'height': 'auto'
    });
});

This approach sets the CSS properties to disable scrolling initially using jQuery, and then reverts them back when the specified element has completed its transition.

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

Authenticating Users with HTML in Django

I am experiencing an issue with the following condition: {% if object.author == user or object.res_person_1_username == user %} When I display variables using code like this: <p class="article-content mb-1"><strong>object.res_person_ ...

Can variables in JavaScript clash with input names in HTML?

I have the following code in an HTML file: <input type="..." name="myInput1" /> Then, in a JS file associated with this HTML file, I declare a variable to store the value of that input after it loses focus: var myInput1; Should I be concerned abo ...

Guide on showcasing various PHP tables based on the selection from a PHP combobox

I am facing a challenge where I need to retrieve multiple queries and display each query in a PHP table when a specific item is selected from a combobox. For instance, upon clicking on the first item listed below, the corresponding table with its respect ...

Ways to align two elements within the same level in the DOM?

Is it really impossible to have two elements render parallel to each other on the z-axis? Even with the same z-index, they are treated as being on different levels based on their order in the DOM. This can be a challenge when trying to display nearby eleme ...

Issue tracking the window scroll in Internet Explorer when using Jquery animation

Is there a way to make a div follow the window's scroll position smoothly? It seems to work fine in Firefox, but in Internet Explorer 6 and 7, the animation causes a jumpy effect with the window scrolling. I've attempted to use easing without su ...

How can you incorporate a custom button into the controlBar on videoJS in responsive mode?

The video player I have created using videoJS includes custom buttons in the control bar. These buttons are not clickable when viewed on mobile or tablet devices without forcing them to work. let myButton = player?.controlBar.addChild('button'); ...

AutoComplete issues a warning in red when the value assigned to the useState hook it is associated with is altered

const [selectedCountry, setSelectedCountry] = useState(); <Autocomplete autoHighlight={true} //required autoSelect={true} id="geo-select-country" options={availableCountries} value={se ...

Having an issue where my form is automatically submitted before the data from the database is fetched to display after scanning a product barcode in a field

Having trouble with PHP - when I scan a product barcode in a field, the form is automatically submitted before fetching data from the database to display in the fields. You can see a screenshot of the form here: https://i.stack.imgur.com/2D7yg.png <f ...

Guide on incorporating pinching gestures for zooming in and out using JavaScript

I have been working on implementing pinch zoom in and out functionality in JavaScript. I have made progress by figuring out how to detect these gestures using touch events. var dist1=0; function start(ev) { if (ev.targetTouches.length == 2) {//checkin ...

Is it possible to use a JavaScript string as a selector in jQuery?

So, my issue is with the following JavaScript code snippet: for ( i=0; i < parseInt(ids); i++){ var vst = '#'+String(img_arr[i]); var dst = '#'+String(div_arr[i]); } I'm wondering how I can proceed in jQuery to handle ...

Is it possible to halt the animation as well as stop the entire action from executing?

I have a background fading in and out on my website. Here is the code for that: // Fading in: $bg.css({'pointerEvents':'auto'}).show() .stop(true).animate({ 'opacity': 0.90 }, animTime); // Fading out: $bg.css({'poi ...

Clickable regions in Internet Explorer 7 that lack a specific width

Is there a way to make the clickable area of links always stretch to the parents container when the parent container does not have a fixed width? For example, check out this JSFiddle. In Firefox, the link stretches with the text and the li tag, but in IE ...

What is the most efficient way to send various props to multiple child components within a React parent component?

Currently, I am working on developing a color palette generator using React. However, I have encountered an issue where all child divs in the color palette receive the same color instead of different colors. Below is the code snippet: class ColorPalet ...

Material UI Grid List rows are displaying with an unusually large gap between them, creating a

Currently, I am utilizing Material UI in combination with Reactjs. One particular issue that I am encountering involves the Grid List Component. In my attempt to establish a grid of 1000x1000px, I have specified the height and width within the custom gridL ...

Switching the default z-index for child elements within an HTML container

According to the specification, elements are typically drawn "in tree order" for in-flow, non-positioned elements of similar block level or float status and identical z-index. This means that elements declared last in the HTML markup appear on top. But wha ...

Only run the final AJAX request

My goal is to use jQuery ajax and php for field validation. Currently, the issue I am facing is that if I type 3 valid characters followed by an invalid one, the request is sent to the PHP file four times. I want to optimize this so that only the last req ...

Incorporating an SVG with CSS styling from a stylesheet

After exploring various articles and questions on the topic, I am yet to find a definitive solution. I have an external file named icon.svg, and my objective is to utilize it across multiple HTML files with different fill colors and sizes for each instanc ...

Easily upload a file by simply selecting it, no need to fill out a form or submit anything

I am working on adding a mail feature to a WordPress admin plugin. My goal is to allow users to attach a file dynamically and send it through email as an attachment. I have implemented an AJAX method for choosing the file upload, but I seem to be stuck. Ca ...

Unable to make the Show/Hide Loading GIF function work as intended

Could someone please help me with my code? I'm trying to display a loading GIF image while waiting for an ajax request to complete. When the button is pressed, I want the loader to be shown until the data is returned from the server. I would greatly ...

The specific div is causing issues with the functionality of the .load jQuery function

Unfortunately, this line is not functioning as intended $('#bookcontainer').load( startSlide ); Conversely, this line works perfectly $(window).load( startSlide ); The element #bookcontainer consists of a collection of four images. Below is ...