How can I force WebKit to redraw/repaint to propagate style changes?

后端 未结 27 2362
我寻月下人不归
我寻月下人不归 2020-11-22 02:04

I have some trivial JavaScript to effect a style change:

sel = document.getElementById(\'my_id\');
sel.className = sel.className.replace(/item-[1-9]-selected         


        
27条回答
  •  走了就别回头了
    2020-11-22 02:31

    I use the transform: translateZ(0); method but in some cases it is not sufficient.

    I'm not fan of adding and removing a class so i tried to find way to solve this and ended up with a new hack that works well :

    @keyframes redraw{
        0% {opacity: 1;}
        100% {opacity: .99;}
    }
    
    // ios redraw fix
    animation: redraw 1s linear infinite;
    

提交回复
热议问题