Compare commits

...

2 Commits

Author SHA1 Message Date
neverland
b4e3c3374c
fix(ImagePreview): incorrectly closed after zooming (#10188) 2022-01-14 17:11:00 +08:00
neverland
481bad5df9
feat(ImagePreview): improve zoom fluency (#10187) 2022-01-14 16:35:37 +08:00
3 changed files with 15 additions and 5 deletions

View File

@ -25,7 +25,7 @@
### 介绍
Vant 是**有赞前端团队**开源的移动端组件库,于 2017 年开源,已持续维护 4 年时间。Vant 对内承载了有赞所有核心业务,对外服务十多万开发者,是业界主流的移动端组件库之一。
Vant 是**有赞前端团队**开源的移动端组件库,于 2017 年开源。Vant 对内承载了有赞所有核心业务,对外服务十多万开发者,是业界主流的移动端组件库之一。
目前 Vant 官方提供了 [Vue 2 版本](https://vant-contrib.gitee.io/vant)、[Vue 3 版本](https://vant-contrib.gitee.io/vant/v3)和[微信小程序版本](http://vant-contrib.gitee.io/vant-weapp),并由社区团队维护 [React 版本](https://github.com/mxdi9i7/vant-react)和[支付宝小程序版本](https://github.com/ant-move/Vant-Aliapp)。

View File

@ -8,7 +8,7 @@
### 介绍
Vant 是**有赞前端团队**开源的移动端组件库,于 2017 年开源,已持续维护 4 年时间。Vant 对内承载了有赞所有核心业务,对外服务十多万开发者,是业界主流的移动端组件库之一。
Vant 是**有赞前端团队**开源的移动端组件库,于 2017 年开源。Vant 对内承载了有赞所有核心业务,对外服务十多万开发者,是业界主流的移动端组件库之一。
目前 Vant 官方提供了 [Vue 2 版本](https://vant-contrib.gitee.io/vant)、[Vue 3 版本](https://vant-contrib.gitee.io/vant/v3)和[微信小程序版本](http://vant-contrib.gitee.io/vant-weapp),并由社区团队维护 [React 版本](https://github.com/mxdi9i7/vant-react)和[支付宝小程序版本](https://github.com/ant-move/Vant-Aliapp)。

View File

@ -106,7 +106,7 @@ export default defineComponent({
});
const setScale = (scale: number) => {
scale = clamp(scale, +props.minZoom, +props.maxZoom);
scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
if (scale !== state.scale) {
state.scale = scale;
@ -131,6 +131,7 @@ export default defineComponent({
state.moveY = 0;
};
let fingerNum: number;
let startMoveX: number;
let startMoveY: number;
let startScale: number;
@ -144,12 +145,13 @@ export default defineComponent({
touch.start(event);
fingerNum = touches.length;
startMoveX = state.moveX;
startMoveY = state.moveY;
touchStartTime = Date.now();
state.moving = touches.length === 1 && state.scale !== 1;
state.zooming = touches.length === 2 && !offsetX.value;
state.moving = fingerNum === 1 && state.scale !== 1;
state.zooming = fingerNum === 2 && !offsetX.value;
if (state.zooming) {
startScale = state.scale;
@ -183,6 +185,10 @@ export default defineComponent({
};
const checkTap = () => {
if (fingerNum > 1) {
return;
}
const { offsetX, offsetY } = touch;
const deltaTime = Date.now() - touchStartTime;
const TAP_TIME = 250;
@ -236,6 +242,10 @@ export default defineComponent({
if (state.scale < 1) {
resetScale();
}
if (state.scale > props.maxZoom) {
state.scale = +props.maxZoom;
}
}
}