Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input field leaving artifacts from CSS3 transition (in Chrome 15)

http://jsfiddle.net/danielcgold/SYgzJ/

When you click on the input then go on blur, artifacts are left on the screen in Chrome 15. I first noticed this issue on a site i've been developing so I eliminated everything but just the input field and a button. When I remove the button, the transition happens just fine. Any ideas?

like image 842
Dan Avatar asked Nov 10 '11 13:11

Dan


Video Answer


2 Answers

Add this CSS to your input field:

input {
    -webkit-transform: translate3d(0,0,0)
}

This will force Chrome to use your GPU to do all the rendering which will solve the artifacts problem and make your animations smother.

like image 182
Cesar Canassa Avatar answered Oct 15 '22 15:10

Cesar Canassa


This is a bug in Chrome's rendering of CSS transitions. But you can workaround it by forcing element "refresh" operation. Please note that you need to refresh not the input element, but it's parent, so the following code will help you:

$(document).ready(function(){
    $('#test').blur(function(){
      $(this).parent().addClass('repaint');
    });
    $('#test').focus(function(){
      $(this).parent().removeClass('repaint');
    });
});

And repaint class should have something related to parent's view, for example different color:

.repaint {
 color: red;
}

But you may replace color with visibility or other view-related (but not important/visible for parent) attribute.

Here is jsfiddle to demonstrate the workaround

like image 40
Pavel Podlipensky Avatar answered Oct 15 '22 15:10

Pavel Podlipensky