Skip to content

Commit d60810c

Browse files
committed
feat(image-viewer): enable props image-props
1 parent 36f96f0 commit d60810c

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ 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+
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
1415
images | Array | [] | Typescript: `Array<string>` | N
1516
initial-index | Number | 0 | Typescript: `Number` | N
1617
lazy | Boolean | true | `1.9.4` | N
1718
show-index | Boolean | false | \- | N
18-
show-menu-by-longpress | Boolean | false | `1.11.3` | N
1919
using-custom-navbar | Boolean | false | `v1.1.4` | N
2020
visible | Boolean | false | hide or show image viewer | N
2121
default-visible | Boolean | undefined | hide or show image viewer。uncontrolled property | N

packages/components/image-viewer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ 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
6364
show-index | Boolean | false | 是否显示页码 | N
64-
show-menu-by-longpress | Boolean | false | `1.11.3`。长按图片显示发送给朋友、收藏、保存图片、搜一搜、打开名片/前往群聊/打开小程序(若图片中包含对应二维码或小程序码)的菜单 | N
6565
using-custom-navbar | Boolean | false | `v1.1.4`。是否使用了自定义导航栏 | N
6666
visible | Boolean | false | 隐藏/显示预览 | N
6767
default-visible | Boolean | undefined | 隐藏/显示预览。非受控属性 | N

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@
3535
<t-image
3636
wx:if="{{!lazy || utils.shouldLoadImage(index, currentSwiperIndex, loadedImageIndexes) }}"
3737
t-class="t-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"
44-
show-menu-by-longpress="{{showMenuByLongpress}}"
4549
></t-image>
4650
</swiper-item>
4751
</swiper>

packages/components/image-viewer/props.ts

Lines changed: 4 additions & 5 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,
@@ -41,11 +45,6 @@ const props: TdImageViewerProps = {
4145
type: Boolean,
4246
value: false,
4347
},
44-
/** 长按图片显示发送给朋友、收藏、保存图片、搜一搜、打开名片/前往群聊/打开小程序(若图片中包含对应二维码或小程序码)的菜单 */
45-
showMenuByLongpress: {
46-
type: Boolean,
47-
value: false,
48-
},
4948
/** 是否使用了自定义导航栏 */
5049
usingCustomNavbar: {
5150
type: Boolean,

packages/components/image-viewer/type.ts

Lines changed: 9 additions & 8 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 []
@@ -61,14 +70,6 @@ export interface TdImageViewerProps {
6170
type: BooleanConstructor;
6271
value?: boolean;
6372
};
64-
/**
65-
* 长按图片显示发送给朋友、收藏、保存图片、搜一搜、打开名片/前往群聊/打开小程序(若图片中包含对应二维码或小程序码)的菜单
66-
* @default false
67-
*/
68-
showMenuByLongpress?: {
69-
type: BooleanConstructor;
70-
value?: boolean;
71-
};
7273
/**
7374
* 是否使用了自定义导航栏
7475
* @default false

0 commit comments

Comments
 (0)