Skip to content

Commit

Permalink
better collapse
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhixin committed Apr 12, 2017
1 parent f00f999 commit f9aecb6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/components/collapse.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<transition name="collapse">
<transition @enter="enter" @leave="leave" name="collapse">
<div :class="classObject" v-show="show">
<slot></slot>
<div ref="content">
<slot></slot>
</div>
</div>
</transition>
</template>
Expand All @@ -10,11 +12,10 @@
.collapse-enter-active, .collapse-leave-active {
transition: all .35s ease;
overflow: hidden;
max-height: 100vh;
}
.collapse-enter, .collapse-leave-to {
max-height: 0;
height: 0;
}
</style>

Expand Down Expand Up @@ -50,6 +51,13 @@
methods: {
toggle() {
this.show = !this.show;
},
enter(el) {
const height = getComputedStyle(this.$refs.content).height;
el.style.height = height;
},
leave(el) {
el.style.height = 0;
}
},
Expand Down

0 comments on commit f9aecb6

Please sign in to comment.