Using the `.animate()` function in JavaScript causes a one-second delay

I'm encountering some difficulties with the .animate() function in Javascript. I'm using it to automatically scroll to an element within a div, which is functioning correctly. However, I am facing an issue where the scrolling freezes for a second after a few milliseconds, then continues from the point it should have animated to already before proceeding smoothly.

The scrollable div contains around 36 divs with a width of 75 px, and there's a dynamically generated SVG graph in the background. To animate the div, I am utilizing:

parent.stop(true, false).animate({
            scrollLeft: offsetToLeft
        }, 50*Math.abs(elementsToSkipp), function (element, index) {
            //Show highlight the element and refresh data
            return false;
        }.bind(this, forecastElement[0], index));

The use of return false; and .stop(true, false) was suggested on Stackoverflow, but it hasn't completely resolved my problem. Any assistance would be greatly appreciated.

EDIT: The lag only occurs on mobile devices (iOS, Android); there are no such issues on a Desktop PC.

Thanks, David

Answer №1

It appears that your animation is triggered by a scroll event. I suggest checking out this helpful post that addresses similar issues and includes code examples: Dealing with slow reaction time in jQuery

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

Grab and drop into place

I have been searching for solutions, but so far I haven't found anything that works for my specific case. I have an upload button that currently works on a click event, but I also want it to be able to drag and drop files for uploading. Here is the H ...

Suggestions to update arbitrary content at a 5-second interval in Vue using Nuxt.js

As a Vue beginner, I am facing an issue with changing random text every 5 seconds while the page is loading. <template> <section class="container"> <h1 class="title"> Welcome {{ whois }} </h1> </section&g ...

Verify the presence of the position

I'm working on a page that contains elements with relative positioning. style="position: relative;" Some of the elements have top and left coordinates while others do not. I am wondering if it's possible to check for the presence of these coord ...

"The latest version of Angular, version 15, experiencing issues with javascript loading

Currently, I am diving into the world of Angular and encountering a puzzling dilemma. Surprisingly, my application performs flawlessly on various browsers such as Chrome, Firefox, Brave, Opera, and even on mobile versions except for Safari. Both the deskto ...

Master the art of crafting precise searches with Js and Jquery

In my quest to create an expanded search function that allows users to find people not only by their names but also using various combinations, I encountered a challenge. For example, I have a list of players and the following code snippet works fine: ...

The utilization of local storage within Backgridjs

I am creating an app using Backbone.js (Marionette Framework) along with additional functionalities like Backgrid, Backbone local storage, Backbone Radio, epoxy, and Backbone relational model. Encountered Problem: An issue arises when utilizing the local ...

Utilize JSON parsing with a reviver parameter to filter out specific object properties

In the process of developing a Node.js server, I am working on a particular service that requires accepting a stringified JSON object while also implementing field whitelisting. To achieve both of these objectives, I intend to utilize JSON.parse() with the ...

Issue with AJAX request on Internet Explorer versions 8 and 9

This script is functioning properly in Internet Explorer 10 and above, as well as Chrome and other browsers. However, it encounters issues specifically with IE8 and IE9. <table id="table" border="1"> <tbody style="display: table-row-group"&g ...

Convenient ways to connect data between a database and Firebase authentication system

After beginning a basic app using Firebase 3 and Angular 1, I implemented an authentication system through Firebase for user registration and login. Currently, I am storing message data in the Firebase database. My main question is: how can I connect user ...

Loop through a list of form names using ng-repeat and send each form name to a JavaScript function when clicked

I have multiple forms within an ng-repeat loop, each with a different name. I need to pass the form data when a button inside the form is clicked. However, when I try to call it like this: checkSaveDisable(updateProductSale_{{productIndex}}) it thro ...

Tips for adjusting the height of an outer div based on the visible inner div heights while scrolling

Here is an example of HTML code with a simple array of integers called Files: [1,2,3,4,5,6] <!doctype html> <html ng-app="Application"> <head> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/an ...

When the click event is triggered, insert HTML content into a div, clear any existing selection from the div, and

Looking to develop a biscuit selector feature that enables users to email their chosen biscuits. I require an on click event that adds the selected biscuit (image) to the biscuit barrel (basket). It should also allow users to remove any biscuits from the ...

Retrieving an Array in CakePHP Through an Ajax Post Request

Despite the countless other 'duplicate' questions on this topic, I still find myself stuck. My goal is simply to log an array passed from PHP via ajax. In CakePHP 2.X: In View: <button class="quarter q1" value="1" value>Quarter 1</but ...

Continuous background image motion descending from the top

Can anyone help me modify this JavaScript code so that the background image moves from top to bottom instead of left to right? <script> $(function(){ var y = 0; setInterval(function(){ y+=1; $('body&a ...

Unresponsive Toggle Button on Bootstrap Navigation Bar

Whenever I resize the window and try to click the navigation toggle button, it doesn't seem to work. The button is unresponsive. Can someone please help me figure out what the issue could be? <nav class="navbar fixed-top navbar-expand-lg navba ...

JavaScript - The left dropdown menu stubbornly remains visible when clicked in white space, unlike the right dropdown which disappears as expected. Puzzled by this inconsistency

Whenever I click on the selection criteria box, a dropdown menu appears. Clicking on the white space or the data table button makes the drop-down menu disappear, which is good. However, when I perform the same action for 'choose data table,' the ...

What could be causing the ::before pseudo element to display on top of the element?

According to my understanding, the ::before pseudo-element should be positioned below the element, while the ::after pseudo-element should appear above it in terms of z-index. In this particular scenario, I am attempting to darken just the background colo ...

What is the reason for always including style-loader, css-loader, and vue-loader content in the webpack4 production bundle?

When building my final bundle with production mode in webpack, I noticed that the exported multiple entry compiled js files always include loaders content. How can I eliminate them and what is the reason for their inclusion? To replicate this issue, follo ...

Date selection tool malfunctioning - unexpected behavior

Struggling to identify where I'm making mistake. The dynamically created input fields with the "freeze-date" class seem to only function correctly on the initial datepicker input field that's generated. You can find the code over at http://jsfidd ...

Can a Javascript function parameter be transferred to PHP?

As I understand it, PHP is used on the server-side and JavaScript is used on the client-side. However, I am curious if there is a way to achieve the following scenario. Imagine having a JavaScript function that makes an Ajax call to a PHP file. Here is an ...