Vue Animation

๋ทฐ ์• ๋‹ˆ๋ฉ”์ด์…˜์€ ๋ทฐ ํ”„๋ ˆ์ž„์›Œํฌ ์ž์ฒด์—์„œ ์ง€์›ํ•˜๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ธฐ๋Šฅ์œผ๋กœ, ๋ฐ์ดํ„ฐ ์ถ”๊ฐ€, ๋ณ€๊ฒฝ, ์‚ญ์ œ์— ๋Œ€ํ•ด์„œ ํŽ˜์ด๋“œ ์ธ, ํŽ˜์ด๋“œ ์•„์›ƒ ๋“ฑ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์• ๋‹ˆ๋ฉ”์ด์…˜ ํšจ๊ณผ๋ฅผ ์ง€์›ํ•œ๋‹ค. ๊ธฐํƒ€ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋‚˜ CSS ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋„ ๊ฐ™์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

<transition-group name="list" tag="ul">
            <li v-for="(todoItem,index) in propsdata" v-bind:key="todoItem" class="shadow">
                <i class="checkBtn fa fa-check" aria-hidden="true"></i>{{ todoItem }}
                <span class="removeBtn" type="button" @click="removeTodo(todoItem, index)"><i class="fas fa-trash" aria-hidden="true"></i></span>
            </li>
</transition-group>
<transition-group name="list" tag="ul"></transition-group>

<transition-group> ํƒœ๊ทธ๋Š” ๋ชฉ๋ก์— ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ถ”๊ฐ€ํ•  ๋•Œ ์‚ฌ์šฉ๋˜๋Š” ํƒœ๊ทธ์ด๋ฉฐ, tag๋ช…์„ ์ง€์ •ํ•˜๋ฉด๋œ๋‹ค. name ์†์„ฑ์€ CSSํด๋ž˜์Šค์™€ ์—ฐ๊ด€์žˆ๋‹ค.

<style>
    .list-item{
        display: inline-block;
        margin-right: 10px;
    }
    .list-move{
        transition: transform 1s;
    }
    .list-enter-active, .list-leave-active{
        transition: all 1s;
    }
    .list-enter, .list-leave-to{
        opacity: 0;
        transform: translateY(30px);
    }
</style>

css ์†์„ฑ์˜ ํด๋ž˜์Šค๋ฅผ ๋ณด๋ฉด ๋ชจ๋‘ ์•ž์—์„œ ์„ค์ •ํ•œ name ์†์„ฑ ๊ฐ’(list)์„ ์ ‘๋‘์‚ฌ๋กœ ๊ฐ–๊ณ  ์žˆ๋‹ค. ๋’ค์—์˜ค๋Š” ๋ถ€๋ถ„์€ ๋ฐ์ดํ„ฐ๊ฐ€ ๋“ค์–ด๊ฐ€๊ณ  ๋‚˜๊ฐ€๋Š” ๋™์ž‘์„ ์ •์˜ํ•˜๋Š” CSS์ด๋‹ค.

์ฐธ์กฐ

Last updated