Do not engage with the website while animations are running

I'm working on a JavaScript project where I want to create textareas that grow and center in the window when clicked, and shrink back down when not focused. However, I ran into some issues with the .animate() function that are causing bugs.

During QA testing, I found several problems:

  • If I click off a textarea while it's still animating its growth, the .blur() function doesn't trigger.
  • If I switch focus to another textarea while the first one is still animating, both may remain large and fail to trigger the .blur() function.
  • There are strange behaviors with the centering feature when using .scrollTo() and .animate() together, especially with multiple textareas or in crowded areas.

Is there a way to prevent any interaction with the website while an animation is in progress? Any ideas on fixing these issues?

The javascript file 'boxy.js' includes the following code:

function growthearea() {
    // JavaScript functions for growing and shrinking textareas
}

function newboxbtn() {
    // Function for creating new textareas with live update functionality
}

function jsinit() {
    // Initialize functions for existing textareas
}

The HTML markup in 'boxy.htm' looks like this:

<html>
<head>
    <!-- CSS and JavaScript links -->
</head>
<body>

    <div class="grid">
        <div class="col-left" id="left">
            <div class="module">
                <input type="button" value="add" onclick="newboxbtn()" />
                <p class="display">You are typing...</p>
            </div>
        </div>

        <div class="col-midd">
            <div class="module" id="locale">
                <textarea class="textfield" placeholder="Begin typing here..."></textarea>
                <textarea class="textfield" placeholder="Begin typing here..."></textarea>
            </div>
        </div>
    </div>

</body>
</html>

The CSS styles in 'sty.css' include rules for textareas, grid layout, modules, and body styling.

Answer №1

If you want to verify if something is in motion: {definitely unusual!}

if($('*').is(':animated').length) return;

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 it permissible to utilize the ::Before::Before element?

While working on a CSS file for a page with a non-editable profile, I encountered the challenge of not being able to add content directly. This limitation prompted me to explore alternative solutions. My idea was to utilize the page ID and incorporate it ...

Showing local storage on a webpage using Jquery

I have encountered an issue where I can successfully add and remove items from local storage, but the added item does not display on my HTML page. The expected behavior is that when an item is added to local storage, it should be visible on a favorites pag ...

Automatically substitute a term with a clickable link

Is there a way to automatically turn every word into a hyperlink? I have specific words that need to be linked. For example, I want Ronaldo (Only for the First Appearance) to link to a certain page. However, my attempted method did not work. <p> Ro ...

Vue template is not being rendered when served through Django

I am currently working on a Django application where Vue is used as the frontend to render templates. In my Django view code, I have the following components: # thing/views.py def index(request): template = loader.get_template('thing/index.html&a ...

The Google Chart is failing to show up on the screen

I'm having trouble implementing a feature that involves selecting a region from a dropdown list and requesting rainfall data to display in a Google Chart. Unfortunately, I've encountered some issues with it. Could you please help me identify ...

Testing HTTP requests on a form click in Vue.js 2 - Let's see how

Within my component, I have the following method: methods:{ ContactUs(){ this.$http.post("/api/contact-us").then((res)=>{ ///do new stuff },(err)=>{ //do new stuff }) ...

FireFox is showing inconsistencies in response to the jQuery GET request, while Chrome is responding correctly

$.ajax({ url: 'https://api.imgur.com/3/album/' + sharedAlbumID, type: 'GET', beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'Client-ID '+imgurClientID);}, success: function(resp) { ...

Exploring Next JS: Effectively altering SVG attributes and incorporating new elements

I have integrated SVGR to load an SVG as a component in my latest Next.js 13 application: import CvSvg from './../../public/image.svg' export default function Home() { return ( <div className="flex flex-col min-h-screen" ...

UI-Router causing issues with AngularJS anchorScroll functionality

Currently, I am utilizing ui-router and attempting to implement automatic scrolling within the controller. However, it seems that anchorScroll function is not working as expected. My assumption is that it may be due to having two '#' symbols in t ...

Step-by-step guide on utilizing jQuery to fade out all elements except the one that is selected

There are multiple li elements created in this way: echo '<ul>'; foreach ($test as $value){ echo '<li class="li_class">.$value['name'].</li>'; } echo '</ul>'; This code will generate the fol ...

Moving an item to the top of an array in JavaScript/Vue.js: A simple guide

const a = [{ "iso2": "KH", "countryName": "Cambodia", "nationality": "Cambodian" }, { "iso2": "KI", "countryName": "Kiribati", "nationality": "I-Kiribati" }, { "iso2": "KM", "countryName": "Comoros", "nationality": "Como ...

Moves are chosen to move downward when positioned next to an inline-block level element

Check out this jsfiddle example How can I prevent selects from moving down when there is an inline-block level element next to it? <select> <option value="" >Day</option> </select><select> <option value="" >Mon ...

Implement JQuery to display a loading message whenever an a tag is clicked

The website's various pages are filled with standard <a> tags, some of which have a class attribute that is utilized for styling using CSS. Each <a> tag includes a href="" attribute linking to another page on the same site. My goal is to d ...

How to center align a button in the footer of a Bootstrap card

I'm currently using Bootstrap 5.1.3 and facing a challenge in centering a button within the footer of a card. Below is the code snippet I am working with: CSS .btnStandard { min-width: 10vw; } HTML <div class="card-footer justify-content- ...

Make sure to keep Vue-Cookies intact even when closing the browser or tab

I have integrated vue-cookies into my Vue application. The code I'm using to store a cookie is as follows: $cookies.set('authUser', authUserObj); The object authUserObj contains the access_token. However, when I close and reopen the ta ...

A recursive approach for constructing a tree structure in Angular

Currently, I am working on a project involving the implementation of crud functions. To display the data in a tree-like structure, I am utilizing the org chart component from the PrimeNg library. The data obtained from the backend is in the form of an arra ...

php and javascript

On my sales website, when I press the "sales" button, it opens a new frame. There is a chance for multiple frames to be open at the same time. My issue is that I want to close the frame after clicking enter and have the home page updated while keeping al ...

Error: Custom Service is behaving unpredictably

My latest project involves creating a customized service. While the service function is returning data as expected, I encounter an issue when calling it in the controller - it returns 'undefined'. Service: var toDoListServices = angular.module( ...

Using Tailwind CSS's width property w-11/12 actually returns a full 100% width instead of the expected 91.66

It seems that the w-11/12 class is not behaving as expected. According to the documentation, it should give a width of 91.666% but instead, it's filling up 100%. This issue only occurs with the value 11, while other values work fine. Has anyone else e ...

Looking to change the date format from 24/05/2021 to 24/May/2021 using jQuery or JavaScript?

My client prefers not to use a date picker, but wants to be able to type dates directly into a textbox and have them automatically converted to the format 24/May/2021 as they leave the field. I am looking for a solution using either Javascript or jQuery. ...