Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/packages/imagepreview/imagepreview.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import React, {
ReactNode,
} from 'react'
import Taro from '@tarojs/taro'
import { ITouchEvent, Video as TaroVideo } from '@tarojs/components'
import { ITouchEvent, Video as TaroVideo, Image } from '@tarojs/components'
import classNames from 'classnames'
import { Close } from '@nutui/icons-react-taro'
import Popup from '@/packages/popup/index.taro'
import Image from '@/packages/image/index.taro'
import Swiper from '@/packages/swiper/index.taro'
import SwiperItem from '@/packages/swiperitem/index.taro'

Expand Down Expand Up @@ -276,7 +275,6 @@ export const ImagePreview: FunctionComponent<Partial<ImagePreviewProps>> = (
className={classNames(classPrefix, className)}
style={style}
ref={ref}
onClick={closeOnImg}
onTouchStart={onTouchStart as any}
>
<Swiper
Expand Down Expand Up @@ -304,6 +302,7 @@ export const ImagePreview: FunctionComponent<Partial<ImagePreviewProps>> = (
>
<TaroVideo
src={item.source.src}
onClick={closeOnImg}
controls={item.options.controls}
autoplay={false}
loop={false}
Expand All @@ -321,15 +320,17 @@ export const ImagePreview: FunctionComponent<Partial<ImagePreviewProps>> = (
key={index}
className="nut-imagepreview-swiper-item"
>
{Taro.getEnv() === 'WEB' ? (
<Image src={item.src} mode="aspectFit" />
) : (
<Image
src={item.src}
mode="aspectFit"
showMenuByLongpress={!!showMenuByLongpress}
/>
)}
(
<Image
src={item.src}
mode="widthFix"
onClick={closeOnImg}
style={{ width: '100%' }}
{...(Taro.getEnv() !== 'WEB' && {
showMenuByLongpress,
})}
/>
)
</SwiperItem>
)
})
Expand Down
15 changes: 11 additions & 4 deletions src/packages/imagepreview/imagepreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export const ImagePreview: FunctionComponent<Partial<ImagePreviewProps>> = (
})
}

const closeOnImg = (e: React.MouseEvent<Element, MouseEvent>) => {
const closeOnImg = (e: any) => {
e.stopPropagation()
// 点击内容区域的图片是否可以关闭弹层(视频区域由于nut-video做了限制,无法关闭弹层)
if (closeOnContentClick) {
Expand All @@ -275,7 +275,6 @@ export const ImagePreview: FunctionComponent<Partial<ImagePreviewProps>> = (
className={classNames(classPrefix, className)}
style={style}
ref={ref}
onClick={closeOnImg}
onTouchStart={onTouchStart as any}
>
{showPop ? (
Expand All @@ -298,7 +297,11 @@ export const ImagePreview: FunctionComponent<Partial<ImagePreviewProps>> = (
? videos.map((item, index) => {
return (
<SwiperItem key={index}>
<Video source={item.source} options={item.options} />
<Video
source={item.source}
options={item.options}
onClick={closeOnImg}
/>
</SwiperItem>
)
})
Expand All @@ -308,7 +311,11 @@ export const ImagePreview: FunctionComponent<Partial<ImagePreviewProps>> = (
? images.map((item, index) => {
return (
<SwiperItem key={index}>
<Image src={item.src} draggable={false} />
<Image
src={item.src}
draggable={false}
onClick={closeOnImg}
/>
</SwiperItem>
)
})
Expand Down