fix(ImagePreview): allow user to swipe to next image when the current image is moved to the edge (#12666)

This commit is contained in:
inottn 2024-03-11 20:55:13 +08:00 committed by GitHub
parent 2b9abfe174
commit f70feab438
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -190,6 +190,7 @@ export default defineComponent({
doubleScale={props.doubleScale} doubleScale={props.doubleScale}
closeOnClickImage={props.closeOnClickImage} closeOnClickImage={props.closeOnClickImage}
closeOnClickOverlay={props.closeOnClickOverlay} closeOnClickOverlay={props.closeOnClickOverlay}
vertical={props.vertical}
onScale={emitScale} onScale={emitScale}
onClose={emitClose} onClose={emitClose}
onLongPress={() => emit('longPress', { index })} onLongPress={() => emit('longPress', { index })}

View File

@ -56,6 +56,7 @@ const imagePreviewItemProps = {
doubleScale: Boolean, doubleScale: Boolean,
closeOnClickImage: Boolean, closeOnClickImage: Boolean,
closeOnClickOverlay: Boolean, closeOnClickOverlay: Boolean,
vertical: Boolean,
}; };
export type ImagePreviewItemProps = ExtractPropTypes< export type ImagePreviewItemProps = ExtractPropTypes<
@ -225,9 +226,10 @@ export default defineComponent({
// if the image is moved to the edge, no longer trigger move, // if the image is moved to the edge, no longer trigger move,
// allow user to swipe to next image // allow user to swipe to next image
if ( if (
(moveX > maxMoveX.value || moveX < -maxMoveX.value) && (props.vertical
!isImageMoved && ? touch.isVertical() && Math.abs(moveY) > maxMoveY.value
touch.isHorizontal() : touch.isHorizontal() && Math.abs(moveX) > maxMoveX.value) &&
!isImageMoved
) { ) {
state.moving = false; state.moving = false;
return; return;