Skip to content

Commit

Permalink
chore(imagepreview): replace var with const (#2423)
Browse files Browse the repository at this point in the history
  • Loading branch information
subordon authored Jul 13, 2023
1 parent f3edeba commit 2dace33
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 61 deletions.
36 changes: 18 additions & 18 deletions src/packages/__VUE/imagepreview/doc.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,23 +308,23 @@ app.use(ImagePreview);

### Props

| Attribute | Description | Type | Default |
| ------------------- | ----------------------------------------------------------- | --------------------------- | ------------------ | --- |
| show | Whether to show preview | boolean | `false` |
| videos | Videos Array(Videos are before images, not support in taro) | VideoArray[] | `[]` |
| images | Images array | ImageArray[] | `[]` |
| autoplay | Autoplay time, zero means not autoplay | number \| string | `3000` |
| init-no | Init no | number | `1` |
| pagination-visible | Whether to show pagination | boolean | `false` |
| pagination-color | Pagination color | string | `#fff` |
| content-close | Click image to exit preview | boolean | `true` |
| show-index | Whether to show index | boolean | `true` |
| closeable | Whether to show close icon | boolean | `false` |
| close-icon-position | Close icon position,can be set to `top-left` | string | `top-right` |
| before-close | Callback function before close | (active: number) => boolean | Promise<`boolean`> | - |
| max-zoom | Max zoom`Taro isn't supported` | number | `3` |
| min-zoom | Min zoom`Taro isn't supported` | number | `1/3` |
| is-Loop | Whether to loop | boolean | `true` |
| Attribute | Description | Type | Default |
| ------------------- | ----------------------------------------------------------- | ------------------------------------------------- | ----------- |
| show | Whether to show preview | boolean | `false` |
| videos | Videos Array(Videos are before images, not support in taro) | VideoArray[] | `[]` |
| images | Images array | ImageArray[] | `[]` |
| autoplay | Autoplay time, zero means not autoplay | number \| string | `3000` |
| init-no | Init no | number | `0` |
| pagination-visible | Whether to show pagination | boolean | `false` |
| pagination-color | Pagination color | string | `#fff` |
| content-close | Click image to exit preview | boolean | `true` |
| show-index | Whether to show index | boolean | `true` |
| closeable | Whether to show close icon | boolean | `false` |
| close-icon-position | Close icon position,can be set to `top-left` | string | `top-right` |
| before-close | Callback function before close | (active: number) => boolean \| Promise<`boolean`> | - |
| max-zoom | Max zoom`Taro isn't supported` | number | `3` |
| min-zoom | Min zoom`Taro isn't supported` | number | `1/3` |
| is-Loop | Whether to loop | boolean | `true` |

### Data Structure of ImageArray

Expand All @@ -344,7 +344,7 @@ app.use(ImagePreview);
| Event | Description | Arguments |
| ------ | ---------------------------------- | --------- |
| close | Emitted when closing ImagePreview | - |
| change | Emitted when current image changed | |
| change | Emitted when current image changed | index |

### Slots

Expand Down
34 changes: 17 additions & 17 deletions src/packages/__VUE/imagepreview/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,23 +306,23 @@ app.use(ImagePreview);

### Props

| 参数 | 说明 | 类型 | 默认值 |
| ------------------- | ------------------------------------------------------------- | --------------------------- | ------------------ | --- |
| show | 是否展示预览图片 | boolean | `false` |
| videos | 预览的视频数组(视频自动放到图片之前) | VideoArray[] | `[]` |
| images | 预览图片数组 | ImageArray[] | `[]` |
| autoplay | 自动轮播时长,0 表示不会自动轮播 | number \| string | `3000` |
| init-no | 初始页码 | number | `1` |
| pagination-visible | 分页指示器是否展示 | boolean | `false` |
| pagination-color | 分页指示器选中的颜色 | string | `#fff` |
| content-close | 点击图片可以退出预览 | boolean | `true` |
| show-index | 是否显示页码 | boolean | `true` |
| closeable | 是否显示关闭图标 | boolean | `false` |
| close-icon-position | 关闭图标位置,可选值:`top-left` | string | `top-right` |
| before-close | 关闭前的回调函数,返回 `false` 可阻止关闭,支持返回 `Promise` | (active: number) => boolean | Promise<`boolean`> | - |
| max-zoom | 手势缩放时,最大缩放比例 | number | `3` |
| min-zoom | 手势缩放时,最小缩放比例 | number | `1/3` |
| is-loop | 是否循环播放 | boolean | `true` |
| 参数 | 说明 | 类型 | 默认值 |
| ------------------- | ------------------------------------------------------------- | ------------------------------------------------- | ----------- |
| show | 是否展示预览图片 | boolean | `false` |
| videos | 预览的视频数组(视频自动放到图片之前) | VideoArray[] | `[]` |
| images | 预览图片数组 | ImageArray[] | `[]` |
| autoplay | 自动轮播时长,0 表示不会自动轮播 | number \| string | `3000` |
| init-no | 初始页码 | number | `0` |
| pagination-visible | 分页指示器是否展示 | boolean | `false` |
| pagination-color | 分页指示器选中的颜色 | string | `#fff` |
| content-close | 点击图片可以退出预览 | boolean | `true` |
| show-index | 是否显示页码 | boolean | `true` |
| closeable | 是否显示关闭图标 | boolean | `false` |
| close-icon-position | 关闭图标位置,可选值:`top-left` | string | `top-right` |
| before-close | 关闭前的回调函数,返回 `false` 可阻止关闭,支持返回 `Promise` | (active: number) => boolean \| Promise<`boolean`> | - |
| max-zoom | 手势缩放时,最大缩放比例 | number | `3` |
| min-zoom | 手势缩放时,最小缩放比例 | number | `1/3` |
| is-loop | 是否循环播放 | boolean | `true` |

### ImageArray 数据结构

Expand Down
28 changes: 14 additions & 14 deletions src/packages/__VUE/imagepreview/doc.taro.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,20 @@ app.use(ImagePreview);

### Props

| 参数 | 说明 | 类型 | 默认值 |
| ------------------- | ------------------------------------------------------------- | --------------------------- | ------------------ | --- |
| show | 是否展示预览图片 | boolean | `false` |
| images | 预览图片数组 | ImageArray[] | `[]` |
| autoplay | 自动轮播时长,0 表示不会自动轮播 | number \| string | `3000` |
| init-no | 初始页码 | number | `1` |
| pagination-visible | 分页指示器是否展示 | boolean | `false` |
| pagination-color | 分页指示器选中的颜色 | string | `#fff` |
| content-close | 点击图片可以退出预览 | boolean | `true` |
| show-index | 是否显示页码 | boolean | `true` |
| closeable | 是否显示关闭图标 | boolean | `false` |
| close-icon-position | 关闭图标位置,可选值:`top-left` | string | `top-right` |
| before-close | 关闭前的回调函数,返回 `false` 可阻止关闭,支持返回 `Promise` | (active: number) => boolean | Promise<`boolean`> | - |
| is-Loop | 是否循环播放 | boolean | `true` |
| 参数 | 说明 | 类型 | 默认值 |
| ------------------- | ------------------------------------------------------------- | ------------------------------------------------- | ----------- |
| show | 是否展示预览图片 | boolean | `false` |
| images | 预览图片数组 | ImageArray[] | `[]` |
| autoplay | 自动轮播时长,0 表示不会自动轮播 | number \| string | `3000` |
| init-no | 初始页码 | number | `0` |
| pagination-visible | 分页指示器是否展示 | boolean | `false` |
| pagination-color | 分页指示器选中的颜色 | string | `#fff` |
| content-close | 点击图片可以退出预览 | boolean | `true` |
| show-index | 是否显示页码 | boolean | `true` |
| closeable | 是否显示关闭图标 | boolean | `false` |
| close-icon-position | 关闭图标位置,可选值:`top-left` | string | `top-right` |
| before-close | 关闭前的回调函数,返回 `false` 可阻止关闭,支持返回 `Promise` | (active: number) => boolean \| Promise<`boolean`> | - |
| is-Loop | 是否循环播放 | boolean | `true` |

### ImageArray 数据结构

Expand Down
21 changes: 9 additions & 12 deletions src/packages/__VUE/imagepreview/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ export default create({
const onTouchStart = (event: TouchEvent) => {
const curTouchTime = new Date().getTime();
const touches = event.touches;
const events = touches[0];
const events2 = touches[1];
const store = state.store;
if (curTouchTime - state.lastTouchEndTime < 300) {
const store = state.store;
if (store.scale > 1) {
store.scale = 1;
} else if (store.scale == 1) {
Expand All @@ -175,11 +179,6 @@ export default create({
scaleNow();
}
var touches = event.touches;
var events = touches[0];
var events2 = touches[1];
const store = state.store;
store.moveable = true;
if (events2) {
Expand All @@ -204,9 +203,9 @@ export default create({
}
const store = state.store;
// event.preventDefault();
var touches = event.touches;
var events = touches[0];
var events2 = touches[1];
const touches = event.touches;
const events = touches[0];
const events2 = touches[1];
// 双指移动
if (events2) {
// 获得当前两点间的距离
Expand All @@ -229,9 +228,7 @@ export default create({
store.scale = store.originScale * curScale;
// 最大放大 3 倍,缩小后松手要弹回原比例
if (store.scale > 3) {
store.scale = 3;
}
state.store.scale = Math.min(state.store.scale, 3);
scaleNow();
}
};
Expand Down

0 comments on commit 2dace33

Please sign in to comment.