Skip to content

Commit

Permalink
refactor(CNavGroup): update event emit
Browse files Browse the repository at this point in the history
  • Loading branch information
mrholek committed Oct 10, 2021
1 parent 0e90bb4 commit 1534ecd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/nav/CNavGroup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { watch } from '@vue/runtime-core'
import { defineComponent, h, onMounted, onUpdated, ref, RendererElement, Transition } from 'vue'

const CNavGroup = defineComponent({
Expand Down Expand Up @@ -44,26 +45,34 @@ const CNavGroup = defineComponent({
}
})

watch(visible, () => {
emit('visible-change', visible.value)
})

const handleTogglerClick = function () {
visible.value = !visible.value
emit('visible-change', visible.value)
}

const handleBeforeEnter = (el: RendererElement) => {
el.style.height = '0px'
navGroupRef.value.classList.add('show')
}

const handleEnter = (el: RendererElement, done: () => void) => {
el.addEventListener('transitionend', () => {
done()
})
el.style.height = `${el.scrollHeight}px`
}

const handleAfterEnter = (el: RendererElement) => {
el.style.height = 'auto'
}

const handleBeforeLeave = (el: RendererElement) => {
el.style.height = `${el.scrollHeight}px`
}

const handleLeave = (el: RendererElement, done: () => void) => {
el.addEventListener('transitionend', () => {
done()
Expand All @@ -72,6 +81,7 @@ const CNavGroup = defineComponent({
el.style.height = '0px'
}, 1)
}

const handleAfterLeave = () => {
navGroupRef.value.classList.remove('show')
}
Expand Down

0 comments on commit 1534ecd

Please sign in to comment.