ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
293 lines • 9.86 kB
TypeScript
import * as i0 from "@angular/core";
import { ElementRef, EventEmitter, OnChanges, OnInit, SimpleChanges } from "@angular/core";
import { NzConfigKey, NzConfigService } from "ng-zorro-antd/core/config";
import { Direction } from "@angular/cdk/bidi";
import { OverlayRef } from "@angular/cdk/overlay";
import { CdkDragEnd } from "@angular/cdk/drag-drop";
import { SafeResourceUrl } from "@angular/platform-browser";
declare namespace image_directive_d_exports {
export { ImageStatusType, NzImageDirective, NzImageScaleStep, NzImageUrl };
}
export type ImageStatusType = 'error' | 'loading' | 'normal';
export type NzImageUrl = string;
export type NzImageScaleStep = number;
export declare class NzImageDirective implements OnInit, OnChanges {
private document;
nzConfigService: NzConfigService;
private elementRef;
private nzImageService;
protected readonly dir: import("@angular/core").WritableSignal<import("@angular/cdk/bidi").Direction>;
private destroyRef;
readonly _nzModuleName: NzConfigKey;
nzSrc: string;
nzSrcset: string;
nzDisablePreview: boolean;
nzFallback: string | null;
nzPlaceholder: string | null;
nzScaleStep: number | null;
backLoadImage: HTMLImageElement;
status: ImageStatusType;
private backLoadDestroy$;
private parentGroup;
get previewable(): boolean;
ngOnInit(): void;
onPreview(): void;
getElement(): ElementRef<HTMLImageElement>;
ngOnChanges(changes: SimpleChanges): void;
/**
* use internal Image object handle fallback & placeholder
*
* @private
*/
private backLoad;
static ɵfac: i0.ɵɵFactoryDeclaration<NzImageDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<NzImageDirective, "img[nz-image]", ["nzImage"], {
"nzSrc": {
"alias": "nzSrc";
"required": false;
};
"nzSrcset": {
"alias": "nzSrcset";
"required": false;
};
"nzDisablePreview": {
"alias": "nzDisablePreview";
"required": false;
};
"nzFallback": {
"alias": "nzFallback";
"required": false;
};
"nzPlaceholder": {
"alias": "nzPlaceholder";
"required": false;
};
"nzScaleStep": {
"alias": "nzScaleStep";
"required": false;
};
}, {}, never, never, true, never>;
static ngAcceptInputType_nzDisablePreview: unknown;
}
export declare class NzImagePreviewOptions {
nzKeyboard?: boolean;
nzNoAnimation?: boolean;
nzMaskClosable?: boolean;
nzCloseOnNavigation?: boolean;
nzZIndex?: number;
nzZoom?: number;
nzRotate?: number;
nzFlipHorizontally?: boolean;
nzFlipVertically?: boolean;
nzScaleStep?: number;
nzDirection?: Direction;
}
export interface NzImage {
src: string;
srcset?: string;
alt?: string;
width?: string | number;
height?: string | number;
}
declare namespace image_preview_component_d_exports {
export { NZ_DEFAULT_SCALE_STEP, NzImageContainerOperation, NzImagePreviewComponent };
}
export interface NzImageContainerOperation {
icon: string;
type: string;
rotate?: number;
onClick(): void;
}
export declare const NZ_DEFAULT_SCALE_STEP = 0.5;
export declare class NzImagePreviewComponent implements OnInit {
private readonly document;
private readonly ngZone;
private readonly cdr;
private readonly nzConfigService;
private readonly sanitizer;
private readonly destroyRef;
readonly elementRef: ElementRef<any>;
readonly config: NzImagePreviewOptions;
readonly _defaultNzZoom = 1;
readonly _defaultNzScaleStep = 0.5;
readonly _defaultNzRotate = 0;
readonly isDragging: import("@angular/core").WritableSignal<boolean>;
images: NzImage[];
index: number;
visible: boolean;
scaleStepMap: Map<NzImageUrl, NzImageScaleStep>;
protected readonly previewImageTransform: import("@angular/core").WritableSignal<string>;
protected readonly previewImageWrapperTransform: import("@angular/core").WritableSignal<string>;
operations: NzImageContainerOperation[];
zoomOutDisabled: boolean;
position: {
x: number;
y: number;
};
previewRef: NzImagePreviewRef;
closeClick: EventEmitter<void>;
imageRef: ElementRef<HTMLImageElement>;
imagePreviewWrapper: ElementRef<HTMLElement>;
private zoom;
private rotate;
private scaleStep;
private flipHorizontally;
private flipVertically;
get maskClosable(): boolean;
constructor();
ngOnInit(): void;
setImages(images: NzImage[], scaleStepMap?: Map<string, number>): void;
switchTo(index: number): void;
next(): void;
prev(): void;
markForCheck(): void;
onClose(): void;
onZoomIn(): void;
onZoomOut(): void;
onRotateRight(): void;
onRotateLeft(): void;
onSwitchLeft(event: MouseEvent): void;
onSwitchRight(event: MouseEvent): void;
onHorizontalFlip(): void;
onVerticalFlip(): void;
wheelZoomEventHandler(event: WheelEvent): void;
onDragEnd(event: CdkDragEnd): void;
sanitizerResourceUrl(url: string): SafeResourceUrl;
private updatePreviewImageTransform;
private updatePreviewImageWrapperTransform;
private updateZoomOutDisabled;
private handlerImageTransformationWhileZoomingWithMouse;
private handleImageScaleWhileZoomingWithMouse;
private isZoomedInWithMouseWheel;
private reset;
private reCenterImage;
static ɵfac: i0.ɵɵFactoryDeclaration<NzImagePreviewComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NzImagePreviewComponent, "nz-image-preview", ["nzImagePreview"], {}, {}, never, never, true, never>;
}
export declare class NzImagePreviewRef {
previewInstance: NzImagePreviewComponent;
private config;
private overlayRef;
private destroy$;
constructor(previewInstance: NzImagePreviewComponent, config: NzImagePreviewOptions, overlayRef: OverlayRef);
private get element();
private get _animationsEnabled();
private _startEnterAnimation;
private _startLeaveAnimation;
switchTo(index: number): void;
next(): void;
prev(): void;
close(): void;
private _doClose;
}
export interface NzImageService {
preview(images: NzImage[], option?: NzImagePreviewOptions): NzImagePreviewRef;
}
export declare class NzImageService {
private injector;
private nzConfigService;
private readonly directionality;
private display;
private attachPreviewComponent;
private createOverlay;
static ɵfac: i0.ɵɵFactoryDeclaration<NzImageService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
}
export declare const NZ_CONFIG_MODULE_NAME: NzConfigKey;
declare namespace image_group_component_d_exports {
export { NzImageGroupComponent };
}
export declare class NzImageGroupComponent {
nzScaleStep: number | null;
images: NzImageDirective[];
addImage(image: NzImageDirective): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NzImageGroupComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NzImageGroupComponent, "nz-image-group", ["nzImageGroup"], {
"nzScaleStep": {
"alias": "nzScaleStep";
"required": false;
};
}, {}, never, ["*"], true, never>;
}
export declare class NzImageModule {
static ɵfac: i0.ɵɵFactoryDeclaration<NzImageModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<NzImageModule, never, [typeof NzImageDirective, typeof NzImagePreviewComponent, typeof NzImageGroupComponent], [typeof NzImageDirective, typeof NzImagePreviewComponent, typeof NzImageGroupComponent]>;
static ɵinj: i0.ɵɵInjectorDeclaration<NzImageModule>;
}
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
/**
* fit content details: https://github.com/NG-ZORRO/ng-zorro-antd/pull/6154#issuecomment-745025554
*
* calc position x,y point
*
* CASE (width <= clientWidth && height <= clientHeight):
*
* ------------- clientWidth -------------
* | |
* | ------ width ------ |
* | | | |
* | | | |
* client height | |
* Height | | |
* | | | |
* | ------------------- |
* | |
* | |
* ---------------------------------------
* fixedPosition = { x: 0, y: 0 }
*
*
*
* CASE (width > clientWidth || height > clientHeight):
*
* ------------- clientWidth -------------
* | | |
* | top |
* | | |
* |--left--|--------------- width -----------------
* | | |
* client | |
* Height | |
* | | |
* | | |
* | height |
* | | |
* ---------| |
* | |
* | |
* | |
* ----------------------------------------
*
*
* - left || top > 0
* left -> 0 || top -> 0
*
* - (left + width) < clientWidth || (top + height) < clientHeight
* - left | top + width | height < clientWidth | clientHeight -> Back left | top + width | height === clientWidth | clientHeight
*
* DEFAULT:
* - hold position
*
*/
export declare function getFitContentPosition(params: {
width: number;
height: number;
left: number;
top: number;
clientWidth: number;
clientHeight: number;
}): {
x?: number;
y?: number;
};
export declare function getOffset(node: HTMLElement): {
left: number;
top: number;
};
export declare function getClientSize(): {
width: number;
height: number;
};