0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

vueで表示を切り替えた項目をフェードインさせる

Last updated at Posted at 2022-07-21

実現したいこと

要素の表示フラグを切り替えた際に、アニメーションでフェードイン/フェードアウトさせる

vue側の記述

isVisibleは表示状態を管理するフラグ

    <div
        :class="{
            fadeIn: isOpen,
            fadeOut: !isOpen,
            'open':isOpen,
            'close':!isOpen,
        }"
    >

css側の記述

.open {
  right: -10px;
  width:200px;
}
.close {
  right: -180px;
  width:200px;
}

.fadeIn {
    animation: fadeIn 1s;
}
@keyframes fadeIn {
    from {
        transform: translateX(100px);
    }
    to {
        transform: translateX(0px);
    }
}

.fadeOut {
    animation: fadeOut 1s;
}
@keyframes fadeOut {
    from {
        transform: translateX(-100px);
    }

    to {
        transform: translateX(0px);
    }
}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?