Skip to content

Commit

Permalink
fix(VSnackbar): close from swipe gesture
Browse files Browse the repository at this point in the history
fixes #3509
  • Loading branch information
johnleider committed Apr 21, 2024
1 parent cbb945d commit 200b3bf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/vuetify/src/components/VSnackbar/VSnackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const VSnackbar = genericComponent<VSnackbarSlots>()({
const overlay = ref<VOverlay>()
const timerRef = ref<VProgressLinear>()
const isHovering = shallowRef(false)
const startY = shallowRef(0)

watch(isActive, startTimeout)
watch(() => props.timeout, startTimeout)
Expand Down Expand Up @@ -147,6 +148,16 @@ export const VSnackbar = genericComponent<VSnackbarSlots>()({
startTimeout()
}

function onTouchstart (event: TouchEvent) {
startY.value = event.touches[0].clientY
}

function onTouchend (event: TouchEvent) {
if (Math.abs(startY.value - event.changedTouches[0].clientY) > 50) {
isActive.value = false
}
}

const locationClasses = computed(() => {
return props.location.split(' ').reduce((acc, loc) => {
acc[`v-snackbar--${loc}`] = true
Expand Down Expand Up @@ -199,6 +210,8 @@ export const VSnackbar = genericComponent<VSnackbarSlots>()({
scrim={ false }
scrollStrategy="none"
_disableGlobalStack
onTouchstart={ onTouchstart }
onTouchend={ onTouchend }
{ ...scopeId }
v-slots={{ activator: slots.activator }}
>
Expand Down

0 comments on commit 200b3bf

Please sign in to comment.