提交 982b3853 编写于 作者: Q qiang

fix: ImagePreview, LocationView use preventScroll

上级 0f49ca95
import { onMounted, onUnmounted } from 'vue'
let index = 0
let overflow = ''
export function preventScroll(prevent: boolean) {
let before = index
index += prevent ? 1 : -1
index = Math.max(0, index)
if (index > 0) {
if (before === 0) {
overflow = document.body.style.overflow
document.body.style.overflow = 'hidden'
}
} else {
document.body.style.overflow = overflow
overflow = ''
}
}
export function usePreventScroll() {
onMounted(() => preventScroll(true))
onUnmounted(() => preventScroll(false))
}
......@@ -7,6 +7,7 @@ import {
computed,
} from 'vue'
import { createSvgIconVNode, ICON_PATH_BACK } from '@dcloudio/uni-core'
import { usePreventScroll } from '../../../../helpers/usePreventScroll'
const props = {
latitude: {
......@@ -36,6 +37,7 @@ export default /*#__PURE__*/ defineComponent({
props,
emits: ['close'],
setup(props, { emit }) {
usePreventScroll()
const mapRef: Ref<HTMLIFrameElement | null> = ref(null)
const key = __uniConfig.qqMapKey
const referer = 'uniapp'
......
......@@ -9,6 +9,7 @@ import {
nextTick,
} from 'vue'
import { Swiper, SwiperItem } from '@dcloudio/uni-components'
import { usePreventScroll } from '../../../../helpers/usePreventScroll'
import ImageView from './ImageView'
const props = {
......@@ -40,6 +41,7 @@ export default /*#__PURE__*/ defineComponent({
props,
emits: ['close'],
setup(props, { emit }) {
usePreventScroll()
const rootRef: Ref<HTMLElement | null> = ref(null)
const indexRef = ref(getIndex(props))
watch(
......@@ -98,6 +100,7 @@ export default /*#__PURE__*/ defineComponent({
>
<Swiper
current={indexRef.value}
// @ts-ignore
onChange={onChange}
indicator-dots={false}
autoplay={false}
......
......@@ -71,6 +71,7 @@ export default /*#__PURE__*/ defineComponent({
return (
<MovableArea
style={viewStyle}
// @ts-ignore
onTouchstart={withWebEvent(onTouchStart)}
onTouchmove={withWebEvent(checkDirection)}
onTouchend={withWebEvent(onTouchEnd)}
......@@ -82,6 +83,7 @@ export default /*#__PURE__*/ defineComponent({
scale
scale-min="1"
scale-max="4"
// @ts-ignore
onScale={onScale}
>
<img
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册