カテゴリー: jQuery

  • [jQuery]fadeInが重いときの対処法

    少しはまったので備忘録

    変更前

    jQuery

    $('.open-btn').on('click', function () {
    	$('.modal').fadeIn().css('display', 'flex');
    });
    $('.close-btn').on('click', function () {
    	$('.modal').fadeOut();
    });

    CSS

    .modal {
        position: fixed;
        width: 100vw;
        height: 100svh;
        z-index: 999999;
        left: 0;
        top: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: scroll;
        display: none;
        background: black;
        transition: .3s;
    }

    変更後

    jQueryは変えずにCSSのtransitionを削除

    CSS

    .modal {
        position: fixed;
        width: 100vw;
        height: 100svh;
        z-index: 999999;
        left: 0;
        top: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: scroll;
        display: none;
        background: black;
        /* transition: .3s; ここを削除  */
    }