반응형
https://kr.vuejs.org/v2/guide/transitions.html
진입/진출 그리고 리스트 트랜지션 — Vue.js
Vue.js - 프로그레시브 자바스크립트 프레임워크
kr.vuejs.org
vue 는 애니메이션, 트렌지션이 프레임워크 자체에서 지원된다.
<TodoList.vue>
<template>
<div>
<transition-group name="list" tag="ul">
<li v-for="(todoItem, index) in propsdata" v-bind:key="todoItem.item" class="shadow">
<i class="checkBth fa-solid fa-check" v-bind:class="{ checkBtnCompleted: todoItem.completed }"
v-on:click="toggleComplete(todoItem, index)"></i>
<!-- 객체.속성값으로 접근 -->
<span v-bind:class="{ textCompleted: todoItem.completed }"> {{ todoItem.item }}</span>
<span class="removeBtn" v-on:click="removeTodo(todoItem, index)">
<i class="fa-solid fa-trash-can"></i>
</span>
</li>
</transition-group>
</div>
</template>
<script>
export default {
props: ['propsdata'],
methods: {
removeTodo(todoItem, index) {
this.$emit('removeItem', todoItem, index);
},
toggleComplete(todoItem, index) {
this.$emit('toggleItem', todoItem, index);
}
},
};
</script>
<style lang="scss" scoped>
ul{
list-style-type: none;
padding-left: 0px;
margin-top: 0;
text-align: left;
}
li{
display: flex;
margin: 10px 0;
min-height: 50px;
height: 50px;
line-height: 50px;
padding: 0 0.9rem;
background: #fff;
border-radius: 5px;
}
.checkBth{
line-height: 45px;
color: #62acde;
margin-right: 5px;
}
.checkBtnCompleted{
color: #b3adad;
}
.textCompleted{
text-decoration: line-through;
color: #b3adad;
}
.removeBtn{
margin-left: auto;
color: #de4343;
}
// 리스트 아이템 트렌지션 효과
.list-enter-active,
.list-leave-active {
transition: all 1s;
}
.list-enter,
.list-leave-to {
/* .list-leave-active below version 2.1.8 */
opacity: 0;
transform: translateX(30px);
}
</style>
반응형
'vue.js > vue.js 2' 카테고리의 다른 글
41. vuex 란? (상태 관리 라이브러리) | Flux 란? (단방향 데이터 처리) (0) | 2022.08.01 |
---|---|
40. 화살표 함수 | Modules (0) | 2022.07.31 |
38. <vue-todo> 사용자 경험 개선 | Modal 컴포넌트 등록 | slot (0) | 2022.07.31 |
35. 파비콘, 아이콘, 구글폰트, 반응형 태그 설정하기 (0) | 2022.07.23 |
34. vue-todo 프로젝트 | 컴포넌트 생성 및 등록 (0) | 2022.07.23 |