Skip to content

Commit

Permalink
fix: TouchEvent not supported in Safari #329 (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterliu1003 committed Feb 14, 2023
1 parent 908621d commit dddb928
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/vue-final-modal/src/dom.ts
@@ -1,12 +1,12 @@
import { noop } from '~/utils'

export const getPosition = (e: TouchEvent | MouseEvent) => {
if (e instanceof TouchEvent) {
const { clientX: x, clientY: y } = e.targetTouches[0]
if (e instanceof MouseEvent) {
const { clientX: x, clientY: y } = e
return { x, y }
}
else {
const { clientX: x, clientY: y } = e
const { clientX: x, clientY: y } = e.targetTouches[0]
return { x, y }
}
}
Expand Down
7 changes: 6 additions & 1 deletion packages/vue-final-modal/src/useSwipeToClose.ts
Expand Up @@ -17,7 +17,12 @@ export function useSwipeToClose(

const vfmContentEl = ref<HTMLDivElement>()
const swipeBannerEl = ref<HTMLDivElement>()
const swipeEl = computed(() => (props.showSwipeBanner ? swipeBannerEl.value : vfmContentEl.value))
const swipeEl = computed(() => {
if (props.swipeToClose === undefined || props.swipeToClose === 'none')
return undefined
else
return (props.showSwipeBanner ? swipeBannerEl.value : vfmContentEl.value)
})

const offset = ref(0)
const isCollapsed = ref<boolean | undefined>(true)
Expand Down

0 comments on commit dddb928

Please sign in to comment.