Skip to content

Commit 107db7a

Browse files
betavsanlyyao
andauthored
feat(image-viewer): enable props image-props (#4078)
* feat(image-viewer): enable props show-menu-by-longpress * feat(image-viewer): enable props image-props * fix: fix cr --------- Co-authored-by: anlyyao <[email protected]>
1 parent b3a2e8a commit 107db7a

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

packages/components/image-viewer/README.en-US.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on v
1111
background-color | String | - | \- | N
1212
close-btn | String / Boolean / Object | false | \- | N
1313
delete-btn | String / Boolean / Object | false | \- | N
14-
images | Array | [] | Typescript:`Array<string>` | N
15-
initial-index | Number | 0 | Typescript:`Number` | N
14+
image-props | Object | - | `1.12.0`。Typescript: `ImageProps`[Image API Documents](./image?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/image-viewer/type.ts) | N
15+
images | Array | [] | Typescript: `Array<string>` | N
16+
initial-index | Number | 0 | Typescript: `Number` | N
1617
lazy | Boolean | true | `1.9.4` | N
1718
show-index | Boolean | false | \- | N
1819
using-custom-navbar | Boolean | false | `v1.1.4` | N

packages/components/image-viewer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场
5757
background-color | String | - | 遮罩的背景颜色 | N
5858
close-btn | String / Boolean / Object | false | 是否显示关闭操作,前提需要开启页码。值为字符串表示图标名称,值为 `true` 表示使用默认图标 `close`,值为 `Object` 类型,表示透传至 `icon` ,不传表示不显示图标 | N
5959
delete-btn | String / Boolean / Object | false | 是否显示删除操作,前提需要开启页码。值为字符串表示图标名称,值为 `true` 表示使用默认图标 `delete`,值为 `Object` 类型,表示透传至 `icon`,不传表示不显示图标 | N
60+
image-props | Object | - | `1.12.0`。透传至 Image 组件。TS 类型:`ImageProps`[Image API Documents](./image?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/image-viewer/type.ts) | N
6061
images | Array | [] | 图片数组。TS 类型:`Array<string>` | N
6162
initial-index | Number | 0 | 初始化页码。TS 类型:`Number` | N
6263
lazy | Boolean | true | `1.9.4`。是否开启图片懒加载。开启后会预加载当前图片、相邻图片 | N

packages/components/image-viewer/image-viewer.wxml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,17 @@
3434
<swiper-item wx:for="{{images}}" wx:key="index" class="{{classPrefix}}__preview-image">
3535
<t-image
3636
wx:if="{{!lazy || utils.shouldLoadImage(index, currentSwiperIndex, loadedImageIndexes) }}"
37-
t-class="t-image--external"
37+
t-class="{{prefix}}-image--external"
38+
class="{{classPrefix}}__image"
3839
style="{{imagesStyle[index].style || ''}}"
39-
mode="aspectFit"
40-
src="{{item}}"
4140
data-index="{{index}}"
42-
class="{{classPrefix}}__image"
41+
src="{{item}}"
42+
mode="{{imageProps && imageProps.mode || 'aspectFit'}}"
43+
lazy="{{imageProps && imageProps.lazy || false}}"
44+
loading="{{imageProps && imageProps.loading || 'default'}}"
45+
shape="{{imageProps && imageProps.shape || 'square'}}"
46+
webp="{{imageProps && imageProps.webp || false}}"
47+
show-menu-by-longpress="{{imageProps && imageProps.showMenuByLongpress || false}}"
4348
bindload="onImageLoadSuccess"
4449
></t-image>
4550
</swiper-item>

packages/components/image-viewer/props.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const props: TdImageViewerProps = {
2121
type: null,
2222
value: false,
2323
},
24+
/** 透传至 Image 组件 */
25+
imageProps: {
26+
type: Object,
27+
},
2428
/** 图片数组 */
2529
images: {
2630
type: Array,

packages/components/image-viewer/type.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
55
* */
66

7+
import { ImageProps } from '../image/index';
8+
79
export interface TdImageViewerProps {
810
/**
911
* 遮罩的背景颜色
@@ -29,6 +31,13 @@ export interface TdImageViewerProps {
2931
type: null;
3032
value?: string | boolean | object;
3133
};
34+
/**
35+
* 透传至 Image 组件
36+
*/
37+
imageProps?: {
38+
type: ObjectConstructor;
39+
value?: ImageProps;
40+
};
3241
/**
3342
* 图片数组
3443
* @default []

0 commit comments

Comments
 (0)