Transition/transform/translate3d in CSS3 may lead to significant flickering on the initial or final "frame" of the transition (specifically on an iPad)

Hello everyone,

I am currently developing a web application specifically for the iPad and I have implemented a CSS3 transition to animate a div, moving it from left to right.

Here is the structure of my class:

.mover {
    -webkit-transition:all 0.4s ease-in-out;
}

Upon clicking a button, the following code is executed:

var newPosition = "translate3d(" + newPosition + "px, 0, 0)";
$('.mover ').css('-webkit-transform', s);

The animation works perfectly fine except for one issue – there is a noticeable flicker the first time the user triggers the transition.

Although I understand that using translate3d may not be necessary since I am only shifting the div horizontally, I believe it forces GPU acceleration on the iPad. Can someone confirm this for me?

Thank you in advance!

[UPDATE]

To clarify about the "flicker" issue – through various experiments with CSS3 transitions on the iPad, I consistently observe a distinct flicker at the beginning or end of the animations.

In essence, the transitions themselves are extremely smooth. However, depending on specific settings, there is a visible flicker just before or after the transition occurs.

For instance, when working with three stacked PNG images, the bottom image has an opacity of 1.0, while the top two have an opacity of 0.0. Utilizing -webkit-keyframes, I achieve seamless fading transitions in between the photos. Yet, as the animation concludes, the bottom photo experiences a brief flicker. It appears as if the browser needs to redraw/re-render the screen, resulting in a slight delay.

This flickering greatly impacts the overall effect and renders the transitions unusable. While barely noticeable on my iMac, it is prominent on the iPad.

Answer №1

I encountered a similar issue and managed to find the solution right here on Stack Overflow: iPhone WebKit CSS animations cause flicker

The fix is quite straightforward:

-webkit-backface-visibility: hidden;

and possibly

-webkit-perspective: 1000;

Add these to each animated object. It resolved the problem for me, hopefully it works for you too.

Answer №2

Greetings,

While I cannot guarantee that this solution is foolproof (especially since the flicker itself can be quite unpredictable), based on personal experience, it appears to address the issue...

Here's what worked for me:

.mover {
    -webkit-transition:all 0.4s ease-in-out;
}

var s = "translate3d(" + newPosition + "px, 0, 0)";
$('.mover ').css('-webkit-transform', s);

Upon initial execution, I noticed a flicker before the animation kicked in. However, subsequent calls ran smoothly without any hiccups.

My interpretation was that setting the 3d coordinates prior to initiating the animation helped eliminate the flicker. The first call establishes these coordinates, ensuring seamless animations with subsequent calls.

Therefore, I made sure to set the 3d coordinates of the element at the beginning (during initialization) before triggering any animations.

By taking this approach, any 3d animations now start from established coordinates, effectively preventing flickering.

While I can't guarantee universal success, this method has proven effective for my current projects.

Best of luck!

Answer №3

Our team managed to eliminate various issues with flickering and fonts by adjusting the viewport settings.

In the past, we encountered problems with content extending beyond the screen (a sliding div), causing the device to struggle when the viewport was not stable. It had difficulty handling data outside the visible area while dealing with the zoom feature of the displayed content.

Adding this meta tag in the head section proved to be the solution to our challenges.

<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">

Answer №4

Give it a shot

.mover {
    position:absolute;
    -webkit-transition:-webkit-transform 0.4s ease-in-out;
} 

However, my understanding is that this compels the iPad to utilize GPU acceleration

Both translate() and translate3d() generate stacking context and could potentially utilize layers - texture buffers in relation to GPU. Thus, I believe they may not have a significant impact on acceleration.

Answer №5

div { -webkit-tap-highlight-color: rgba(255, 255, 255, 0); }

Upon observation, I found that when adding a hover state to a div, the page would flicker inexplicably, even without any attached CSS or JS. Without seeing your HTML code, this tip might be useful in resolving the issue.

Answer №6

After struggling with a similar issue, I attempted all of the suggestions provided in this thread. What finally resolved the problem for me was realizing that the z-index values of the elements were causing the flickering.

In my case, I had three panes arranged in a specific way: one flat middle pane flanked by two angled ones like this \_/. The middle pane kept flickering because its z-index was either equal to or higher than the side panels. Once I moved it to the bottom on the z-axis, the flickering completely disappeared.

Just wanted to share in case anyone else encounters the same issue.

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 possible to rotate an image with a random angle when hovering in Angular?

I'm currently working on a photo gallery project and my goal is to have the images rotate when hovered over. However, I am experiencing difficulties in passing values from TypeScript into the CSS. HTML <div class="back"> <div cl ...

When multiple instances are present, the functionality of dynamically generated jQuery functions ceases to operate effectively

I've developed a chat application similar to hangouts where clicking on a user generates the chat div. One feature I have is allowing users to press enter in a textarea to send text, but when multiple dynamically generated jQuery functions are present ...

I am not getting any emails when users click on the "Pay Now" button

I am currently learning PHP and working on a website that integrates with the paytm gateway. I have a registration page with a "Pay Now" button, but when someone clicks on it, they are directed to pgRedirect.php (provided by paytm). I would like to recei ...

There was a problem locating the animation entry named "routeAnimation" within the app: [ERROR ->]<app></app>. This issue occurred at Directive e within the e_Host@0:0

I'm currently working on implementing animations during route changes. Here is my code snippet: @Component({ selector: 'app', encapsulation: ViewEncapsulation.None, styleUrls: [ './app.css' ], template: totTemplate, ...

Using PHP's header() function in combination with jQuery Mobile to create

Is it possible to redirect using a php header('Location: newpage.php')? Even though I did not encounter any errors, Jquery mobile appears to be unsuccessful in loading the destination page and the address bar remains with the old address. Any s ...

Utilizing jQuery's AJAX GET method with custom parameters to retrieve webpage content

Seeking assistance with using jQuery's get function to call a php script. The php script returns a variable containing the main content of my page, excluding the header/footer. The goal is to update the page content without a reload. Any insights on ...

Jhipster - Simplifying Session Authentication with the Power of Jquery

I have completed the following tasks. Developed a Jhipster application with Http Session Authentication Configured Cors settings I am experiencing issues authenticating through Jquery ajax. I keep encountering the error message below. { "timestamp" : ...

Locating the value of a data attribute from a distant parent div using jQuery

How can I access the closest div from an anchor tag that has a data-id attribute without using multiple parent() methods? Even though .parent().parent().parent() works, I am trying to find a better solution. <div class="panel panel-default" data-id="@ ...

Styling the checked state of a switch in NativeScript/Angular with ngModel/FormBuilder

Let's explore the styling of a switch element within Angular: <Switch class="switch" formControlName="answer"></Switch> One approach involves targeting the switch with checked attribute, setting its background-color and text color accord ...

Is there a way to adjust the font size of a select option?

Looking to customize the appearance of a select option dropdown list. Wondering if it's possible to change the font sizes of individual options rather than keeping them all the same? For instance, having the default: -- Select Country -- displayed a ...

The width of Material UI Grid decreases every time it is re-rendered

I'm attempting to display a list of 25 words in a 5x5 grid using the MUI Grid component. The grid is structured as a <Grid container direction="column"> with five <Grid item> elements. Each <Grid item> contains: <Grid co ...

Display a preview of a React component

Currently facing a challenge where I need to create a form for users to adjust the title, background color, button background, text color, and other settings of a component. I want to provide a live preview of the component as the user makes changes. I en ...

Utilizing Javascript in Spotfire for enhanced functionality

Currently, I have a dropdown menu with two options ("START" & "END"). Depending on the selected value from this dropdown, I want to display a specific DIV element. I attempted to use the code below, but unfortunately, it is not functioning as expected ...

What is the best way to change the content in a textarea field?

I am looking to create a functionality where a div is displayed below selected text inside a textarea. Below is the JavaScript code: function getSel() { var txtarea = document.getElementById("mytextarea"); var start = txtarea.selectionStart; ...

Does the jQuery selector match an unset class?

Encountering an issue with a classed based switch in jQuery code, not sure if it's my mistake or a bug. Take a look at this example: // Expecting only one run // Instead it keeps triggering $('.switch').click(function () { // Show mess ...

Is there a bug causing the Admin LTE content height issue? Looking for solutions to fix it

What's the reason behind the oversized footer? The footer appears normal when I resize or zoom the page, why is that? How can this be resolved? ...

Combining two arrays in a view and then storing them in a database using Codeigniter

Hello everyone, I am a new member on this platform... Currently, I am working with the codeigniter framework and have two separate arrays in my view. The first array includes data from a form input named customerData, customerData = { customerid ...

Using AJAX to load dynamically generated DIV IDs

On my website, I have a "command center" bar featuring a log in / log out button, a my account button, and a messages button. When the user is not logged in, only the login button is displayed. However, once the user logs in, the command center shows the l ...

Two divisions inside another "wrapper" division - Adjusting the width

I'm facing an issue with my CSS. I have a container div "container" that contains two other divs - "left" and "main". The width of the container is set to 90% of the body's width, with a margin of 3% auto to center it. .container{ margin:3% auto ...

Update the div each time the MySQL table is refreshed

My website functions as a messaging application that currently refreshes every 500ms by reading the outputs of the refresh.php file. I'm looking to explore the possibility of triggering the refresh function only when the 'messages' table upd ...