Skip to content

Commit

Permalink
feat(VNavigationDrawer): add delay functionality for rail
Browse files Browse the repository at this point in the history
resolves #18413
  • Loading branch information
johnleider committed Apr 6, 2024
1 parent 44e5588 commit 0201c01
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { makeBorderProps, useBorder } from '@/composables/border'
import { useBackgroundColor } from '@/composables/color'
import { makeComponentProps } from '@/composables/component'
import { provideDefaults } from '@/composables/defaults'
import { makeDelayProps, useDelay } from '@/composables/delay'
import { makeDisplayProps, useDisplay } from '@/composables/display'
import { makeElevationProps, useElevation } from '@/composables/elevation'
import { makeLayoutItemProps, useLayoutItem } from '@/composables/layout'
Expand Down Expand Up @@ -84,6 +85,7 @@ export const makeVNavigationDrawerProps = propsFactory({

...makeBorderProps(),
...makeComponentProps(),
...makeDelayProps(),
...makeDisplayProps(),
...makeElevationProps(),
...makeLayoutItemProps(),
Expand Down Expand Up @@ -118,6 +120,10 @@ export const VNavigationDrawer = genericComponent<VNavigationDrawerSlots>()({
const rootEl = ref<HTMLElement>()
const isHovering = shallowRef(false)

const { runOpenDelay, runCloseDelay } = useDelay(props, value => {
isHovering.value = value
})

const width = computed(() => {
return (props.rail && props.expandOnHover && isHovering.value)
? Number(props.width)
Expand Down Expand Up @@ -201,22 +207,15 @@ export const VNavigationDrawer = genericComponent<VNavigationDrawerSlots>()({
},
})

function onMouseenter () {
isHovering.value = true
}
function onMouseleave () {
isHovering.value = false
}

useRender(() => {
const hasImage = (slots.image || props.image)

return (
<>
<props.tag
ref={ rootEl }
onMouseenter={ onMouseenter }
onMouseleave={ onMouseleave }
onMouseenter={ runOpenDelay }
onMouseleave={ runCloseDelay }
class={[
'v-navigation-drawer',
`v-navigation-drawer--${location.value}`,
Expand Down

0 comments on commit 0201c01

Please sign in to comment.