end of jquery fadeIn() has a 'bump' in Chrome

蹲街弑〆低调 提交于 2019-12-20 03:23:27

问题


I'm using a very simple fadeIn and fadeOut in Chrome. I just want one text element to fade out and another to fade in. Working example: http://jsfiddle.net/forgetcolor/7eR5Q/

The problem I'm having is that at the end of the fadeIn() there is an abrupt transition to the end state. I call it a 'bump'. The element fadesIn smoothly, but right at the end it loses that smoothness and finishes the fade all at once.

Is there a way to avoid this?

var cur = 1;
$('#btn').click(function() {

    if (cur == 1) {
        $('#txt1').fadeOut(500, function() {
            $('#txt2').fadeIn(500);
        });
        cur = 2;
    } else if (cur == 2) {
        $('#txt2').fadeOut(500, function() {
            $('#txt1').fadeIn(500);
        });
        cur = 1;
    }
});​

body {
    background-color:#666;
    color:white;
    font-size:20px;
    margin:20px;
}
#txt2 {display:none;}​

<div id="txt1">txt1</div>
<div id="txt2">txt2</div>
<br/><div id="btn">btn</div>​

UPDATE:

Here's a video: http://www.youtube.com/watch?v=n2IGED0pkVg

My Chrome version number is 20.0.1132.21 beta (latest right now) on OSX

Chrome bug report submitted: https://code.google.com/p/chromium/issues/detail?id=130801


回答1:


If I go ahead and turn off the webkit font smoothing, the dissolve works great: http://jsfiddle.net/7eR5Q/19/ So apparantly it removes the smoothing during the transition and adds it after causing the "bump"




回答2:


If you feel like the fadeIn is happening too quickly, increase the time up to 600,

$('#txt1').fadeIn(600); and $('#txt2').fadeIn(600);

seemed a bit more even for me.




回答3:


It seems to be the font smooth rendering bugging on macbooks. Here is an question from stackoverflow of it.

Edit: you can improve you font rendering with font smoothing in antialiased (spec) mode. And here is an article why you shouldn't use it in general.

-webkit-font-smoothing: antialiased;




回答4:


For future users who come across this, I found this solution worked for me.

-webkit-opacity: .99;


来源:https://stackoverflow.com/questions/10856728/end-of-jquery-fadein-has-a-bump-in-chrome

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!