Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Last active April 21, 2018 04:41
Show Gist options
  • Save andreasvirkus/3373c2e5058445f83dc06df5b9c5bcfb to your computer and use it in GitHub Desktop.
Save andreasvirkus/3373c2e5058445f83dc06df5b9c5bcfb to your computer and use it in GitHub Desktop.
Dropdown in Vue
<template>
<transition name="dropdown"
@enter="setHeight"
@after-enter="unsetHeight"
@before-leave="setHeight">
<slot></slot>
</transition>
</template>
<script>
export default {
name: 'SidebarGroup',
methods: {
setHeight (items) {
// explicitly set height so that it can be transitioned
items.style.height = items.scrollHeight + 'px'
},
unsetHeight (items) {
items.style.height = ''
}
}
}
</script>
<style>
.dropdown-enter,
.dropdown-leave-to {
height 0 !important
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment