Skip to content

Commit 994707b

Browse files
committed
fix: image animation & zindex, close #6675
1 parent e9d26f2 commit 994707b

File tree

2 files changed

+40
-39
lines changed

2 files changed

+40
-39
lines changed

components/image/style/index.ts

+22-23
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import { resetComponent, textEllipsis } from '../../style';
88

99
export interface ComponentToken {
1010
zIndexPopup: number;
11+
previewOperationSize: number;
12+
previewOperationColor: string;
13+
previewOperationColorDisabled: string;
1114
}
1215

1316
export interface ImageToken extends FullToken<'Image'> {
1417
previewCls: string;
1518
modalMaskBg: string;
16-
imagePreviewOperationDisabledColor: string;
17-
imagePreviewOperationSize: number;
1819
imagePreviewSwitchSize: number;
19-
imagePreviewOperationColor: string;
2020
}
2121

2222
export type PositionType = 'static' | 'relative' | 'fixed' | 'absolute' | 'sticky' | undefined;
@@ -45,19 +45,17 @@ export const genImageMaskStyle = (token: ImageToken): CSSObject => {
4545
padding: `0 ${paddingXXS}px`,
4646
[iconCls]: {
4747
marginInlineEnd: marginXXS,
48+
svg: {
49+
verticalAlign: 'baseline',
50+
},
4851
},
4952
},
5053
};
5154
};
5255

5356
export const genPreviewOperationsStyle = (token: ImageToken): CSSObject => {
54-
const {
55-
previewCls,
56-
modalMaskBg,
57-
paddingSM,
58-
imagePreviewOperationDisabledColor,
59-
motionDurationSlow,
60-
} = token;
57+
const { previewCls, modalMaskBg, paddingSM, previewOperationColorDisabled, motionDurationSlow } =
58+
token;
6159

6260
const operationBg = new TinyColor(modalMaskBg).setAlpha(0.1);
6361
const operationBgHover = operationBg.clone().setAlpha(0.2);
@@ -68,7 +66,7 @@ export const genPreviewOperationsStyle = (token: ImageToken): CSSObject => {
6866
display: 'flex',
6967
flexDirection: 'row-reverse',
7068
alignItems: 'center',
71-
color: token.imagePreviewOperationColor,
69+
color: token.previewOperationColor,
7270
listStyle: 'none',
7371
background: operationBg.toRgbString(),
7472
pointerEvents: 'auto',
@@ -78,13 +76,14 @@ export const genPreviewOperationsStyle = (token: ImageToken): CSSObject => {
7876
padding: paddingSM,
7977
cursor: 'pointer',
8078
transition: `all ${motionDurationSlow}`,
79+
userSelect: 'none',
8180

8281
'&:hover': {
8382
background: operationBgHover.toRgbString(),
8483
},
8584

8685
'&-disabled': {
87-
color: imagePreviewOperationDisabledColor,
86+
color: previewOperationColorDisabled,
8887
pointerEvents: 'none',
8988
},
9089

@@ -100,7 +99,7 @@ export const genPreviewOperationsStyle = (token: ImageToken): CSSObject => {
10099
},
101100

102101
'&-icon': {
103-
fontSize: token.imagePreviewOperationSize,
102+
fontSize: token.previewOperationSize,
104103
},
105104
},
106105
};
@@ -110,7 +109,7 @@ export const genPreviewSwitchStyle = (token: ImageToken): CSSObject => {
110109
const {
111110
modalMaskBg,
112111
iconCls,
113-
imagePreviewOperationDisabledColor,
112+
previewOperationColorDisabled,
114113
previewCls,
115114
zIndexPopup,
116115
motionDurationSlow,
@@ -130,21 +129,22 @@ export const genPreviewSwitchStyle = (token: ImageToken): CSSObject => {
130129
width: token.imagePreviewSwitchSize,
131130
height: token.imagePreviewSwitchSize,
132131
marginTop: -token.imagePreviewSwitchSize / 2,
133-
color: token.imagePreviewOperationColor,
132+
color: token.previewOperationColor,
134133
background: operationBg.toRgbString(),
135134
borderRadius: '50%',
136135
transform: `translateY(-50%)`,
137136
cursor: 'pointer',
138137
transition: `all ${motionDurationSlow}`,
139138
pointerEvents: 'auto',
139+
userSelect: 'none',
140140

141141
'&:hover': {
142142
background: operationBgHover.toRgbString(),
143143
},
144144

145145
[`&-disabled`]: {
146146
'&, &:hover': {
147-
color: imagePreviewOperationDisabledColor,
147+
color: previewOperationColorDisabled,
148148
background: 'transparent',
149149
cursor: 'not-allowed',
150150
[`> ${iconCls}`]: {
@@ -153,7 +153,7 @@ export const genPreviewSwitchStyle = (token: ImageToken): CSSObject => {
153153
},
154154
},
155155
[`> ${iconCls}`]: {
156-
fontSize: token.imagePreviewOperationSize,
156+
fontSize: token.previewOperationSize,
157157
},
158158
},
159159

@@ -295,17 +295,11 @@ const genPreviewMotion: GenerateStyle<ImageToken> = token => {
295295
export default genComponentStyleHook(
296296
'Image',
297297
token => {
298-
const imagePreviewOperationColor = new TinyColor(token.colorTextLightSolid);
299298
const previewCls = `${token.componentCls}-preview`;
300299

301300
const imageToken = mergeToken<ImageToken>(token, {
302301
previewCls,
303-
imagePreviewOperationColor: imagePreviewOperationColor.toRgbString(),
304-
imagePreviewOperationDisabledColor: new TinyColor(imagePreviewOperationColor)
305-
.setAlpha(0.25)
306-
.toRgbString(),
307302
modalMaskBg: new TinyColor('#000').setAlpha(0.45).toRgbString(), // FIXME: Shared Token
308-
imagePreviewOperationSize: token.fontSizeIcon * 1.5, // FIXME: fontSizeIconLG
309303
imagePreviewSwitchSize: token.controlHeightLG,
310304
});
311305

@@ -318,5 +312,10 @@ export default genComponentStyleHook(
318312
},
319313
token => ({
320314
zIndexPopup: token.zIndexPopupBase + 80,
315+
previewOperationColor: new TinyColor(token.colorTextLightSolid).toRgbString(),
316+
previewOperationColorDisabled: new TinyColor(token.colorTextLightSolid)
317+
.setAlpha(0.25)
318+
.toRgbString(),
319+
previewOperationSize: token.fontSizeIcon * 1.5, // FIXME: fontSizeIconLG
321320
}),
322321
);

components/vc-image/src/Preview.tsx

+18-16
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,11 @@ const Preview = defineComponent({
311311

312312
return () => {
313313
const { visible, prefixCls, rootClassName } = props;
314-
315314
return (
316315
<Dialog
317316
{...attrs}
318-
transitionName="zoom"
319-
maskTransitionName="fade"
317+
transitionName={props.transitionName}
318+
maskTransitionName={props.maskTransitionName}
320319
closable={false}
321320
keyboard
322321
prefixCls={prefixCls}
@@ -327,19 +326,22 @@ const Preview = defineComponent({
327326
rootClassName={rootClassName}
328327
getContainer={props.getContainer}
329328
>
330-
<ul class={`${props.prefixCls}-operations`}>
331-
{tools.map(({ icon: IconType, onClick, type, disabled }) => (
332-
<li
333-
class={classnames(toolClassName, {
334-
[`${props.prefixCls}-operations-operation-disabled`]: disabled && disabled?.value,
335-
})}
336-
onClick={onClick}
337-
key={type}
338-
>
339-
{cloneVNode(IconType, { class: iconClassName })}
340-
</li>
341-
))}
342-
</ul>
329+
<div class={[`${props.prefixCls}-operations-wrapper`, rootClassName]}>
330+
<ul class={`${props.prefixCls}-operations`}>
331+
{tools.map(({ icon: IconType, onClick, type, disabled }) => (
332+
<li
333+
class={classnames(toolClassName, {
334+
[`${props.prefixCls}-operations-operation-disabled`]:
335+
disabled && disabled?.value,
336+
})}
337+
onClick={onClick}
338+
key={type}
339+
>
340+
{cloneVNode(IconType, { class: iconClassName })}
341+
</li>
342+
))}
343+
</ul>
344+
</div>
343345
<div
344346
class={`${props.prefixCls}-img-wrapper`}
345347
style={{

0 commit comments

Comments
 (0)