DropdownTransition.vue 561 B

123456789101112131415161718192021222324252627282930313233
  1. <template>
  2. <transition
  3. name="dropdown"
  4. @enter="setHeight"
  5. @after-enter="unsetHeight"
  6. @before-leave="setHeight"
  7. >
  8. <slot />
  9. </transition>
  10. </template>
  11. <script>
  12. export default {
  13. name: 'DropdownTransition',
  14. methods: {
  15. setHeight (items) {
  16. // explicitly set height so that it can be transitioned
  17. items.style.height = items.scrollHeight + 'px'
  18. },
  19. unsetHeight (items) {
  20. items.style.height = ''
  21. }
  22. }
  23. }
  24. </script>
  25. <style lang="stylus">
  26. .dropdown-enter, .dropdown-leave-to
  27. height 0 !important
  28. </style>