[new feature] ImagePreview: add max-zoom、min-zoom prop (#3133)

This commit is contained in:
neverland
2019-04-11 14:38:46 +08:00
committed by GitHub
parent b4fc5df926
commit e6d4f331a8
5 changed files with 17 additions and 3 deletions

View File

@@ -5,8 +5,6 @@ import Swipe from '../swipe';
import SwipeItem from '../swipe-item';
const [sfc, bem] = use('image-preview');
const MAX_ZOOM = 3;
const MIN_ZOOM = 1 / 3;
function getDistance(touches) {
return Math.sqrt(
@@ -36,6 +34,14 @@ export default sfc({
type: Boolean,
default: true
},
minZoom: {
type: Number,
default: 1 / 3
},
maxZoom: {
type: Number,
default: 3
},
overlayClass: {
type: String,
default: 'van-image-preview__overlay'
@@ -160,7 +166,7 @@ export default sfc({
if (this.zooming && touches.length === 2) {
const distance = getDistance(touches);
const scale = (this.startScale * distance) / this.startDistance;
this.scale = range(scale, MIN_ZOOM, MAX_ZOOM);
this.scale = range(scale, this.minZoom, this.maxZoom);
}
},