Conflict between CSS transition and jQuery fade

前端 未结 3 1266
一整个雨季
一整个雨季 2021-01-13 09:31

I\'m trying to create a tiled wall with a little menu to display: none some elements based on their class. In my CSS I have CSS transitions which are causing

3条回答
  •  孤独总比滥情好
    2021-01-13 09:50

    In case Hector's solution doesn't work for you, here's an even uglier solution. (Where we eliminate JQuery's call all together)

    Example of fadeOut:

    $('#test').css('opacity', 0);
    window.setTimeout(function() {
         $('#test').remove();
    }, $('#test').css('transition-duration').replace('s','')*1000);
    

    Essentially we are relying to the CSS transition to do the transition and then we are simply waiting in the JS the duration of the transition as defined by the CSS.

提交回复
热议问题