CSS3 animations with transform causes blurred elements on Webkit

前端 未结 2 1218
無奈伤痛
無奈伤痛 2020-12-30 00:48

So I\'ve got some native elements (divs) with various effects applied to them (border-radius, box-shadow and transform: scale()<

相关标签:
2条回答
  • 2020-12-30 00:53

    The best way I found is to wait the animation is complete, then apply the transforms directly to the element and remove the animation class. Something like this works for me, producing no glitches:

    $m.bindOnce($m('win-text'), 'webkitAnimationEnd', function(){ //avoid blurred problem with animating scale property in webkit
        $m('win-text').style.webkitTransform = 'scale(1.5) translateY(-60px)';
        $m.removeClass($m('win-text'), 'final');
    });
    

    I'm using a different library than jQuery, but you get the idea.

    0 讨论(0)
  • 2020-12-30 01:00

    Refer to this answer as to why it's blurring the element: https://stackoverflow.com/a/4847445/814647

    Summary of the above: WebKit is taking the original size/CSS before animating, and treating it as an image, THEN scales it up, producing the blurriness.

    Solution: Make initial size the largest scale you're going to, and start it initially with a lower scale (so in your case you'd want to up the size by 5, and set the initial scale to 0.2)

    UPDATE

    The reason it ignores the current scale from what I understand is because you're not specifically setting JUST the translate (I'm looking up the CSS for it now). When you run -webkit-animation, it's resetting all your current transforms (scale), so you need to make sure that you have your scales in there. I'm looking up the css to change so it only changes just the position:

    0 讨论(0)
提交回复
热议问题