Safari 5 experiences delays with JQuery and CSS3 animations

Encountering issues with jQuery animations specifically in Safari 5 on my Windows system.

Struggling with a simple image fade slider that still has some flickering. The slider involves click events moving two pages at once, one active page right and the other inactive page left.

The script used can be accessed here: fiddle

The key point is switching classes to utilize CSS3 animations for element movement, although previously jQuery was used with similar results.

$('.page.inactive').addClass('moveRight').find('#blurWall').addClass('moveLeftBlur');
$('.page.active').addClass('moveLeft').find('#blurWall').addClass('moveRightBlur');

These additional classes have the following styles:

.moveRight 
{
    -webkit-animation-name: moveRight;
    -webkit-animation-duration:2s;
    -webkit-animation-iteration-count: 1;
    -webkit-animation-timing-function: ease;
    -webkit-animation-fill-mode: forwards;
}
@-webkit-keyframes moveRight 
{
    from {  left:-1286px; }
    to {    left:107px; }
}
.moveLeft 
{
    -webkit-animation-name: moveLeft;
    -webkit-animation-duration:2s;
    -webkit-animation-iteration-count: 1;
    -webkit-animation-timing-function: ease;
    -webkit-animation-fill-mode: forwards;
}
@-webkit-keyframes moveLeft 
{
    from {  left:107px; }
    to {    left:-1286px;   }
}

The website can be found at:fiddle

All images are optimized for web use. The link above is purely for observing the effect and functions flawlessly in Chrome.

Any suggestions on eliminating the lag?

Answer №1

Comparing the use of jQuery with CSS animations, it is evident that there is little difference between them. Both methods involve moving elements using left/right positioning, which lacks efficiency as it is not hardware accelerated. In cases like yours, where there is a heavy reliance on images and constant background-position changes (such as in a slider), this approach can negatively impact the frames per second (FPS).

To address this issue, it is recommended to utilize the transform property instead, as it enforces hardware acceleration:

@-webkit-keyframes moveRight {
  from {
    -webkit-transform: translate3d(-1286px, 0,0);
  }
  to {
    -webkit-transform: translate3d(107px, 0,0);
  }
}

@-webkit-keyframes moveLeft {
  from {
    -webkit-transform: translate3d(107px, 0,0);
  }
  to {
    -webkit-transform: translate3d(-1286px, 0,0);
  }
}

This adjustment should result in a significant improvement in FPS. A benchmark comparison conducted on your page showed a noticeable difference when using the transform method over traditional left/right positioning.

While there may still be occasional drops below 30fps with the transform method, other factors on the page, such as auto-scrolling and complex image sliders, could also contribute to performance issues.

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 can you add a new div directly after the parent div's content and display it in-line?

I have a banner that stretches to fill the width completely. Inside this main div, there is another smaller div measuring 30px in size positioned at the end. The nested div contains a close icon background image, and upon clicking it, the entire banner get ...

Array and setInterval are utilized to compute transitions accurately

I have been working on creating a dynamic element that gathers necessary information from data fields within the element. To achieve this, I utilized JavaScript to create arrays and iterate through them to retrieve the required data. Although I was success ...

Animating a div using jQuery to scroll across the screen and then return

I've been inspired by a feature on the Ben the Bodyguard website and I'm trying to figure out how it's done. From what I can tell, it involves some kind of loop, but I'm not exactly sure how to execute it. The specific part I'm re ...

Does setting `mobile.ajaxEnabled = false` prevent any ajax calls from functioning?

Consider the scenario where I have set $.mobile.ajaxEnabled = false; for page navigation when a page is displayed. Will this action prevent all ajax calls from functioning? For instance, if I had a button that triggered an ajax call upon being clicked. If ...

Attempting to create a JavaScript function that will show a JSON array when the next button is clicked

I am facing an issue with displaying a JSON array based on specific start and end indices. Even though I managed to display the entire array, the first button click does not seem to work as expected. Upon clicking the first button, an error message "this.d ...

What sets apart the `ajax:send` event from the `click` event is that it specifically triggers an ajax

Currently, I am utilizing ajax requests with coffee in my Rails project as shown below. $('#reload').on( 'click': -> $('#response').html "<div class='panel'><img src='assets/load.gif'/> ...

Avoid running another process before the current one finishes in jQuery

I have a situation where I am using $.ajax inside a for loop in jQuery. for(var i=0; i < 2; i++) { $.ajax({ url :"/models/getdata"+i, dataType:"json", success:function(data) { } }); } The issue is that before the success function for i=0 completes, ...

Is the stylesheet connected but failing to load?

Updating an app from Rails 3.2 to version 4 has been mostly successful, but I am encountering issues with some of my stylesheets not being applied correctly. Checking the source code (ctr+U), everything appears to be linked properly: <!DOCTYPE html> ...

Items outside the container element

I recently noticed an issue with my website, which is built using Bootstrap. The problem arises when users scroll down the page and encounter the fixed navigation menu. It appears that the menu items and logo are no longer contained within the designated ...

Display the user's input value in a tooltip without using jQuery

I am looking to achieve this particular layout design. https://i.stack.imgur.com/p9UTH.jpg I am unsure about how to display the input value in the bubble within this layout. The visibility of the bubble should only be triggered on hover. Below is the cod ...

Ensures that two divs have the same dimensions

Currently, I have a line of sections set up like this: I am attempting to ensure that the second div matches the height of the first one, despite the fact that their heights are determined by the size of the pictures which may vary. Do you have any sugges ...

Bizarre display of miscellaneous items on the monitor

Hey there, I've been working on creating a div to display information about both the Civilian and Vehicle that users input. Initially, everything worked perfectly with my HTML and CSS until I introduced two additional divs into the layout. With just o ...

The ejs file is failing to load the css file

I'm facing an issue where my layout.ejs file is not loading the style.css file. I've been searching endlessly for a solution, trying various fixes and meticulously checking for typos. Despite the correct path shown in the network tab when inspect ...

Dragging a div element within a table

I am working on an HTML code where I need to make the colored divs draggable and fit them into specific table cells. The green div should occupy 2 cell spaces, light blue 3 cell spaces, yellow 4 cell spaces, and dark blue 5 cell spaces. While I have the d ...

PHP and jQuery: tackling quotation mark problems in output

Need help with PHP output: $this->Js->buffer(" var searchTerm = $(this).html(); var searchId = $(this).attr('data-tag'); $('.tags').append('<input type='text' value='+searchTerm+' name=&apo ...

Switch a div to a computed location

I'm having trouble getting this code to animate a div to a calculated position. Can someone please help me troubleshoot? $(document).ready(function() { var is_Clicked = false; $("#togglebutton").click(function() { if (is_Cli ...

Updating the $_GET parameter using JQuery when a button is clicked

I'm working on implementing a feature where a series of buttons can update the $_GET['year'] variable on my website. These buttons should function across different pages within my website, such as: example.com example.com/?search=foo exa ...

On the initial page load, Magento is failing to load the CSS properly

I've been tinkering with the Magento website over at For some reason, the CSS on the Home page doesn't load initially, but it loads fine when you click on any other link like Products or Gallery. Any ideas why this might be happening? Thanks in ...

Unable to perform multi-delete action upon clicking the checkbox button as intended

Within my GridView, I have implemented a Multi-delete feature. Below is the code snippet for your reference:- <script type="text/javascript> function ValidateAll() { var chkselectcount = 0; var gridview = document.getElementById( ...

ways to run php script based on screen resolution or size

I have 2 php files that I need to execute based on screen size. include_once('large.php'); include_once('small.php'); The condition is to run large.php when the screen size is greater than 992px, and small.php when the screen size is ...