@@ -36,6 +36,8 @@ export interface PreviewProps extends Omit<IDialogChildProps, 'onClose' | 'mask'
36
36
close ?: VNode ;
37
37
left ?: VNode ;
38
38
right ?: VNode ;
39
+ flipX ?: VNode ;
40
+ flipY ?: VNode ;
39
41
} ;
40
42
}
41
43
@@ -60,10 +62,13 @@ const Preview = defineComponent({
60
62
props : previewProps ,
61
63
emits : [ 'close' , 'afterClose' ] ,
62
64
setup ( props , { emit, attrs } ) {
63
- const { rotateLeft, rotateRight, zoomIn, zoomOut, close, left, right } = reactive ( props . icons ) ;
65
+ const { rotateLeft, rotateRight, zoomIn, zoomOut, close, left, right, flipX, flipY } = reactive (
66
+ props . icons ,
67
+ ) ;
64
68
65
69
const scale = shallowRef ( 1 ) ;
66
70
const rotate = shallowRef ( 0 ) ;
71
+ const flip = reactive ( { x : 1 , y : 1 } ) ;
67
72
const [ position , setPosition ] = useFrameSetState < {
68
73
x : number ;
69
74
y : number ;
@@ -130,6 +135,15 @@ const Preview = defineComponent({
130
135
const onRotateLeft = ( ) => {
131
136
rotate . value -= 90 ;
132
137
} ;
138
+
139
+ const onFlipX = ( ) => {
140
+ flip . x = - flip . x ;
141
+ } ;
142
+
143
+ const onFlipY = ( ) => {
144
+ flip . y = - flip . y ;
145
+ } ;
146
+
133
147
const onSwitchLeft : MouseEventHandler = event => {
134
148
event . preventDefault ( ) ;
135
149
// Without this mask close will abnormal
@@ -180,6 +194,16 @@ const Preview = defineComponent({
180
194
onClick : onRotateLeft ,
181
195
type : 'rotateLeft' ,
182
196
} ,
197
+ {
198
+ icon : flipX ,
199
+ onClick : onFlipX ,
200
+ type : 'flipX' ,
201
+ } ,
202
+ {
203
+ icon : flipY ,
204
+ onClick : onFlipY ,
205
+ type : 'flipY' ,
206
+ } ,
183
207
] ;
184
208
185
209
const onMouseUp : MouseEventHandler = ( ) => {
@@ -365,7 +389,9 @@ const Preview = defineComponent({
365
389
src = { combinationSrc . value }
366
390
alt = { props . alt }
367
391
style = { {
368
- transform : `scale3d(${ scale . value } , ${ scale . value } , 1) rotate(${ rotate . value } deg)` ,
392
+ transform : `scale3d(${ flip . x * scale . value } , ${ flip . y * scale . value } , 1) rotate(${
393
+ rotate . value
394
+ } deg)`,
369
395
} }
370
396
/>
371
397
</ div >
0 commit comments