@@ -37,7 +37,7 @@ import { getClientSize, getFitContentPosition, getOffset } from './utils';
3737export interface NzImageContainerOperation {
3838 icon : string ;
3939 type : string ;
40-
40+ rotate ?: number ;
4141 onClick ( ) : void ;
4242}
4343
@@ -67,7 +67,13 @@ const NZ_DEFAULT_ROTATE = 0;
6767 [class.ant-image-preview-operations-operation-disabled]="zoomOutDisabled && option.type === 'zoomOut'"
6868 (click)="option.onClick()"
6969 >
70- <span class="ant-image-preview-operations-icon" nz-icon [nzType]="option.icon" nzTheme="outline"></span>
70+ <span
71+ class="ant-image-preview-operations-icon"
72+ nz-icon
73+ [nzType]="option.icon"
74+ [nzRotate]="option.rotate ?? 0"
75+ nzTheme="outline"
76+ ></span>
7177 </li>
7278 }
7379 </ul>
@@ -185,6 +191,21 @@ export class NzImagePreviewComponent implements OnInit {
185191 this . onRotateLeft ( ) ;
186192 } ,
187193 type : 'rotateLeft'
194+ } ,
195+ {
196+ icon : 'swap' ,
197+ onClick : ( ) => {
198+ this . onHorizontalFlip ( ) ;
199+ } ,
200+ type : 'flipHorizontally'
201+ } ,
202+ {
203+ icon : 'swap' ,
204+ onClick : ( ) => {
205+ this . onVerticalFlip ( ) ;
206+ } ,
207+ type : 'flipVertically' ,
208+ rotate : 90
188209 }
189210 ] ;
190211
@@ -200,6 +221,8 @@ export class NzImagePreviewComponent implements OnInit {
200221 private zoom : number ;
201222 private rotate : number ;
202223 private scaleStep : number ;
224+ private flipHorizontally : boolean ;
225+ private flipVertically : boolean ;
203226
204227 get animationDisabled ( ) : boolean {
205228 return this . config . nzNoAnimation ?? false ;
@@ -223,6 +246,8 @@ export class NzImagePreviewComponent implements OnInit {
223246 this . zoom = this . config . nzZoom ?? this . _defaultNzZoom ;
224247 this . scaleStep = this . config . nzScaleStep ?? this . _defaultNzScaleStep ;
225248 this . rotate = this . config . nzRotate ?? this . _defaultNzRotate ;
249+ this . flipHorizontally = this . config . nzFlipHorizontally ?? false ;
250+ this . flipVertically = this . config . nzFlipVertically ?? false ;
226251 this . updateZoomOutDisabled ( ) ;
227252 this . updatePreviewImageTransform ( ) ;
228253 this . updatePreviewImageWrapperTransform ( ) ;
@@ -329,6 +354,16 @@ export class NzImagePreviewComponent implements OnInit {
329354 this . next ( ) ;
330355 }
331356
357+ onHorizontalFlip ( ) : void {
358+ this . flipHorizontally = ! this . flipHorizontally ;
359+ this . updatePreviewImageTransform ( ) ;
360+ }
361+
362+ onVerticalFlip ( ) : void {
363+ this . flipVertically = ! this . flipVertically ;
364+ this . updatePreviewImageTransform ( ) ;
365+ }
366+
332367 onAnimationStart ( event : AnimationEvent ) : void {
333368 if ( event . toState === 'enter' ) {
334369 this . setEnterAnimationClass ( ) ;
@@ -379,7 +414,9 @@ export class NzImagePreviewComponent implements OnInit {
379414 }
380415
381416 private updatePreviewImageTransform ( ) : void {
382- this . previewImageTransform = `scale3d(${ this . zoom } , ${ this . zoom } , 1) rotate(${ this . rotate } deg)` ;
417+ this . previewImageTransform = `scale3d(${ this . zoom * ( this . flipHorizontally ? - 1 : 1 ) } , ${
418+ this . zoom * ( this . flipVertically ? - 1 : 1 )
419+ } , 1) rotate(${ this . rotate } deg)`;
383420 }
384421
385422 private updatePreviewImageWrapperTransform ( ) : void {
@@ -416,6 +453,8 @@ export class NzImagePreviewComponent implements OnInit {
416453 this . zoom = this . config . nzZoom ?? this . _defaultNzZoom ;
417454 this . scaleStep = this . config . nzScaleStep ?? this . _defaultNzScaleStep ;
418455 this . rotate = this . config . nzRotate ?? this . _defaultNzRotate ;
456+ this . flipHorizontally = false ;
457+ this . flipVertically = false ;
419458 this . position = { ...initialPosition } ;
420459 }
421460}
0 commit comments