Skip to content

Commit

Permalink
Revert "fix: bug 3lang3#678"
Browse files Browse the repository at this point in the history
This reverts commit 599c750.
  • Loading branch information
nieyunliang committed Apr 8, 2024
1 parent 599c750 commit bd00972
Show file tree
Hide file tree
Showing 4 changed files with 2,127 additions and 2,251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const ImagePreview = React.forwardRef<ImagePreviewRef, ImagePreviewProps>(
defaultIndex={props.startPosition}
onIndexChange={onSwipeChange}
images={props.images}
lazyload={props.lazyload}
onTap={() => {
if (!props.closeOnlyClickCloseIcon) {
onClose()
Expand Down
34 changes: 6 additions & 28 deletions packages/react-vant/src/components/image-preview/slide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ import { bound } from '../utils/bound'
import { rubberbandIfOutOfBounds } from '../utils/rubberband'
import clsx from 'clsx'
import { createNamespace } from '../utils'
import { LazyImageType } from '../image/PropsType'
import Lazyload from '../lazyload'
import { getLazyImagePlaceholder } from '../image/LazyImage'

type Props = {
image: string
maxZoom: number
lazyload?: LazyImageType
onTap: () => void
onZoomChange?: (zoom: number) => void
dragLockRef?: MutableRefObject<boolean>
Expand All @@ -31,13 +27,6 @@ export const Slide: FC<Props> = props => {
config: { tension: 200 },
}))

const { lazyload } = props

const renderPlaceholder = () => {
if (typeof lazyload === 'boolean') return getLazyImagePlaceholder(bem)
return lazyload.placeholder || getLazyImagePlaceholder(bem)
}

const pinchLockRef = useRef(false)

function boundXY([x, y]: [number, number], rubberband: boolean) {
Expand Down Expand Up @@ -174,23 +163,12 @@ export const Slide: FC<Props> = props => {
scale: zoom,
}}
>
{props.lazyload ? (
<Lazyload placeholder={renderPlaceholder()}>
<img
ref={imgRef}
src={props.image}
draggable={false}
alt={props.image}
/>
</Lazyload>
) : (
<img
ref={imgRef}
src={props.image}
draggable={false}
alt={props.image}
/>
)}
<img
ref={imgRef}
src={props.image}
draggable={false}
alt={props.image}
/>
</animated.div>
</div>
</div>
Expand Down
3 changes: 0 additions & 3 deletions packages/react-vant/src/components/image-preview/slides.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import { bound } from '../utils/bound'
import { createNamespace, unitToPx } from '../utils'
import clsx from 'clsx'
import { useUpdateEffect } from '../hooks'
import { LazyImageType } from '../image/PropsType'

export type SlidesType = {
images: string[]
onTap: () => void
maxZoom: number
defaultIndex: number
lazyload?: LazyImageType
onIndexChange?: (index: number) => void
}

Expand Down Expand Up @@ -109,7 +107,6 @@ export const Slides = forwardRef<SlidesRef, SlidesType>((props, ref) => {
}
}}
dragLockRef={dragLockRef}
lazyload={props.lazyload}
/>
))}
</animated.div>
Expand Down
Loading

0 comments on commit bd00972

Please sign in to comment.