import { CollectionViewer, ListRange } from '@angular/cdk/collections'; import { AfterViewInit, EventEmitter, NgZone, OnDestroy, OnInit, Renderer2 } from '@angular/core'; import { Observable, Subject } from 'rxjs'; import { DatastoreAdapterServiceBase } from './classes/datastore-adapter.service.base'; import { ProgressiveImage } from './classes/progressive-image.class'; import { CreateMigImage, GetImageSize, GetMinAspectRatio, UrlForImageFromDimensions } from './interfaces/mig-common.types'; import { MigImageData } from './interfaces/mig-image-data.interface'; import * as i0 from "@angular/core"; export declare class MatImageGridLibComponent = ProgressiveImage> implements AfterViewInit, OnDestroy, OnInit, CollectionViewer { private renderer2; private ngZone; /** * Default implementation of the function that gets the URL for a thumbnail image with the given data & dimensions. * This is a arrow function as it uses the 'this' context of the instance. * This method is located here so that it can be used as a default value for 'urlForThumbnail'. * @param singleImageData - The properties of one image (e.g. containing the imageId). * @param imageWidth - The width (in pixels) of the image. * @param imageHeight - The height (in pixels) of the image. * @returns The URL of the image with the given size. */ private urlForThumbnailDefault; PostViewportLoadBufferMultiplier: number; PostViewportDomBufferMultiplier: number; PreViewportDomBufferMultiplier: number; PreViewportTriggerLoadBufferMultiplier: number; PreViewportLoadBufferMultiplier: number; ScrollDirectionChangeThreshold: number; spaceBetweenImages: number; thumbnailSize: number; withImageClickEvents: boolean; datastore: DatastoreAdapterServiceBase; urlForImage: UrlForImageFromDimensions; urlForThumbnail: UrlForImageFromDimensions; createMigImage: CreateMigImage; getMinAspectRatio: GetMinAspectRatio; getImageSize: GetImageSize; numberOfImagesOnServer: EventEmitter; numberOfImagesOnServerFiltered: EventEmitter; imageClicked: EventEmitter; /** Implementation of the 'CollectionViewer' interface. Used by the dataSource object as parameter of the connect method. Emits when the rendered view of the data changes. */ readonly viewChange: Subject; loading$: Observable; private migContainer; private migGrid; private scrollable; private resizable; private migContainerNative; private migGridNative; private images; private containerWidth; private containerHeight; private totalHeight; private latestViewportTop; private minAspectRatio; private scrollDirection; private triggerPointLoadImages; private indexFirstLoadedImage; private indexFirstPositionedImage; private indexLastPositionedImage; private indexLastImageEverPositioned; private yBottomLastImageEverPositioned; private averageImagesPerRow; private averageHeightOfRow; private serverDataTotals; private readonly unsubscribe$; private dataSource; /** Emits when new data is available. */ private dataFromDataSource; private dataFromDataSourceTotals; private dataFromDataSourceImages; private requestDataFromServer$; private loadingService; constructor(renderer2: Renderer2, ngZone: NgZone); ngOnInit(): void; ngAfterViewInit(): void; ngOnDestroy(): void; /** * Reset the variables used to create the floating average of * the height of a row and the number of images per row. * These values are used to calculate the total height of the grid, * even when we do not have loaded all images. */ private resetAverageValues; /** * Get the Y position of the top of an image. * @param index index of the image in this.images * @returns Y position of the top of an image */ private topOfImage; private get topFirstPositionedRow(); /** * Get the Y position of the bottom of an image including * the space between the rows. * @param index index of the image in this.images * @returns Y position of the bottom of the image including the space between the rows */ private bottomOfImage; private get bottomLastPositionedRow(); /** * Get the y-position above the viewport, from where we don't need * images in the load buffer any more, when scrolling down. * @returns y-position of the start of the load buffer when scrolling down */ private loadBufferStartScrollDown; /** * Get the y-position above the viewport, from where we don't need * images in the load buffer any more, when scrolling up. * @returns y-position of the start of the load buffer when scrolling up */ private loadBufferStartScrollUp; /** * Get the y-position above the viewport, from where we don't need * images in the load buffer any more, * @returns y-position of the start of the load buffer */ private get loadBufferStart(); /** * Get the y-position below the viewport, from where we don't need images * in the load buffer any more, when scrolling down. * @returns y-position of the end of the load buffer when scrolling down */ private loadBufferEndScrollDown; /** * Get the y-position below the viewport, from where we don't need images * in the load buffer any more, when scrolling up. * @returns y-position of the end of the load buffer when scrolling up */ private loadBufferEndScrollUp; /** * Get the y-position below the viewport, from where we don't need * images in the load buffer any more, * @returns y-position of the end of the load buffer */ private get loadBufferEnd(); /** * Get the y-position above the viewport, from where we don't need * images in the DOM any more, when scrolling down. * @returns y-position of the start of the DOM buffer when scrolling down */ private domBufferStartScrollDown; /** * Get the y-position above the viewport, from where we don't need * images in the DOM any more, when scrolling up. * @returns y-position of the start of the DOM buffer when scrolling up */ private domBufferStartScrollUp; /** * Get the y-position above the viewport, from where we don't need * images in the DOM buffer any more, * @returns y-position of the start of the DOM buffer */ private get domBufferStart(); /** * Get the y-position below the viewport, from where we don't need * images in the DOM any more, when scrolling down. * @returns y-position of the end of the DOM buffer when scrolling down */ private domBufferEndScrollDown; /** * Get the y-position below the viewport, from where we don't need * from where we don't need images in the DOM any more. * @returns y-position of the end of the DOM buffer when scrolling up */ private domBufferEndScrollUp; /** * Get the y-position below the viewport, from where we don't need * images in the DOM buffer any more, * @returns y-position of the end of the DOM buffer */ private get domBufferEnd(); /** * Initialize requestDataFromServer$. * Remove duplicate requests and set loading indicator. */ private initRequestSubject; private initDataFromDataSourceTotals; private initDataFromDataSourceImages; /** * Get the definition for the data to import at the beginning of the images array. * @param imagesFromServer - list of images data returned by the server * @param indexOfFirstImageFromServer - where to place the first image from the server into this.images array * @returns ServerData[] with the definition for the data to import */ private selectDataToImportAtStart; /** * Convert list of images information from server to internal representation required * by the image grid and add it to the start of this.images. * @param imageDataToAdd - list of Image details from server (information about each image) * @param startIndex - index in this.images array, where to insert the new images */ private importImageDataAtStart; /** * Extract the data to import at the end of the images array from the data returned by the server. * @param imagesFromServer - list of images data returned by the server * @param indexOfFirstImageFromServer - where to place the first image from the server into this.images array * @returns ServerData[] with the definition for the data to import */ private selectDataToImportAtEnd; /** * Convert list of images information from server to internal representation required * by the image grid and add it to the end of this.images. * @param imageDataToAppend - list of Image details (information about each image) to append */ private importImageDataAtEnd; /** * * subtract diffOfTopInPx from the Y position of each positioned image * to move all images in grid to a new vertical position. * @param diffOfTopInPx - number of pixels to subtract from the Y position of each image */ private moveAllPositionedImagesBy; private initOnScroll; private initOnResize; /** * Clear internal ist of images information. * This method must be called, while material-image-grid is disabled (with method 'disable()')! */ private clearImageData; /** * Creates new instances of the MigImage class for each of the images defined in `imageData`. * @param imageData - An array of metadata about each image from the matImageGridImageService * @param startImageIndex - index of first image in imageData, after adding it to this.images array * @returns An array of MigImage instances */ private parseImageData; /** * This computes the layout of the images in the given range, setting the height, * width, translateX, translateY, and transition values for each ProgressiveImage * `this.images`. These styles are set on the ProgressiveImage.style property, * but are not set in the DOM. * * This separation of concerns (computing layout and DOM manipulation) is * paramount to the performance of mat-image-grid. While we need to manipulate * the DOM every time we scroll (adding or remove images, etc.), we only need * to compute the layout of the mat-image-grid on loading new data and on resize. * Therefore, this function will compute the layout of the images in the given * range but will **not** manipulate the DOM at all. * * All DOM manipulation occurs in `showImagesInViewport`. * * This method handles positioning images at the start of the images list * (images that have been deleted, when scrolling down). * @param startIndex - index of the first image to position in grid * @param endIndexExclusive - index of the first image beyond the positioned range */ private computeLayoutAtStart; /** * This computes the layout of the images in the given range, setting the height, * width, translateX, translateY, and transition values for each ProgressiveImage * `this.images`. These styles are set on the ProgressiveImage.style property, * but are not set in the DOM. * * This separation of concerns (computing layout and DOM manipulation) is * paramount to the performance of mat-image-grid. While we need to manipulate * the DOM every time we scroll (adding or remove images, etc.), we only need * to compute the layout of the mat-image-grid on loading new data and on resize. * Therefore, this function will compute the layout of the images in the given * range but will **not** manipulate the DOM at all. * * All DOM manipulation occurs in `showImagesInViewport`. * * This method handles positioning images at the end of the images list. * @param startIndex - index of the first image to position in grid * @param endIndexExclusive - index of the first image beyond the positioned range * @returns true=image grid height must be adjusted, as average values have been changed */ private computeLayoutAtEnd; /** * Add a row of images to the calculation of the average values. * Average values are the height of a row and the number of images per row. * The average values are used to estimate the required height of the image grid (even when not * all images have already been loaded). * @param indexLastImageInRow - index of the last image in the row * @param imagesInRow - number of images in the row * @param heightOfRow - height of the row * @param yBottomRow - Y of bottom of the row * @returns true=the average value has been changed */ private addRowToAverage; /** * Set y position where to start loading more images when scrolling down. */ private setReloadTriggerScrollDown; /** * Set y position where to start loading more images when scrolling up. */ private setReloadTriggerScrollUp; /** * Set y position where to start loading more images for * both scrolling directions. */ private setReloadTrigger; /** * Update the DOM to reflect the style values of each image in 'images' * field of this component, adding or removing images appropriately. * * Mat-image-grid ensures that there are not too many images loaded into the * DOM at once by maintaining buffer regions around the viewport in which * images are allowed, removing all images below and above. Because all of * our layout is computed using CSS transforms, removing an image above the * buffer will not cause the grid to reshuffle. * * The Pre-Buffers are the buffers in the direction the user is scrolling. * (Below if they are scrolling down, above if they are scrolling up.) The * size of this buffer determines the experience of scrolling down the page. * * The Post-Buffers are the buffers in the opposite direction of the users * scrolling. The size of this buffer determines the experience of changing * scroll directions. (Too small, and we have to reload a ton of images above * the viewport if the user changes scroll directions.) * * While the layout of all loaded images have been computed, only images within * the viewport, the PreViewportDomBuffer and the PostViewportDomBuffer will * exist in the DOM. */ private showImagesInViewport; /** * Event handler for images grid scroll event (triggered by cdkScrollable). * When called in this.scrollable observable, this event handler runs outside * the Angular zone. */ private onContentScrolled; /** * Delete images from the start of the load cache ('this.images') when scrolling down. */ private deleteImagesAtStart; /** * Delete images from the end of the load cache ('this.images') when scrolling up. */ private deleteImagesAtEnd; private onResized; /** * Get the index of the first image visible in viewport. * @returns index of the first visible image or -1 (if no image is visible) */ private indexOfScrollTop; /** * Set the height of the images container based on the images already positioned * and on an estimation about the height required by the remaining images. * for the 'images already positioned' indexOfLastPositionedImage and * bottomOfLastPositionedRow is used; i.e. images that were once positioned and * then later removed while scrolling up are ignored. */ private setImageGridHeight; /** * Request images from the dataSource to fill the viewport, the Pre- and the Post-ViewportDomBuffer * and the Pre- and the Post-ViewportLoadBuffer. */ private fillViewport; /** * Request images from the dataSource to fill the viewport and the buffers * when scrolling down. */ private fillViewportScrollDown; /** * Request images from the dataSource to fill the viewport and the buffers * when scrolling up. */ private fillViewportScrollUp; /** * Request images data from server. * @param indexStart - index of first image to load * @param indexEndExclusive - index of last image to load + 1 */ private requestDataFromServer; /** * Default implementation of the function that gets the URL for an image with the given data & dimensions. * @param singleImageData - The properties of one image (e.g. containing the imageId). * @param imageWidth - The width (in pixels) of the image. * @param imageHeight - The height (in pixels) of the image. * @returns The URL of the image with the given size. */ private urlForImageDefault; /** * Create a new instance of the MigImage class. * The MigImage class represents 1 image in the image grid. * @param renderer - Renderer to be injected into ProgressiveImage constructor. * @param singleImageData - Data from the server describing the image. * @param index - Index of the image in the list of all images (0..n-1). * @param configuration - Configuration data for this image. * @returns New instance of the MigImage class. */ private createMigImageDefault; /** * Default implementation to get the minimum required aspect ratio for a * valid row of images. The perfect rows are maintained by building up a * row of images by adding together their aspect ratios (the aspect ratio * when they are placed next to each other) until that aspect ratio exceeds * the value returned by this function. Responsive reordering is achieved * through changes to what this function returns at different values of the * passed parameter `lastWindowWidth`. * @param lastWindowWidth - The last computed width of the browser window. * @returns The minimum aspect ratio at this window width. */ private getMinAspectRatioDefault; /** * Default implementation to get the image size (height in pixels) to use * for this window width. * Responsive resizing of images is achieved through changes to what this * function returns at different values of the passed parameter `lastWindowWidth`. * @param lastWindowWidth - The last computed width of the images container. * @returns The size (height in pixels) of the images to load. */ private getImageSizeDefault; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵcmp: i0.ɵɵComponentDeclaration, "mat-image-grid", never, { "PostViewportLoadBufferMultiplier": { "alias": "PostViewportLoadBufferMultiplier"; "required": false; }; "PostViewportDomBufferMultiplier": { "alias": "PostViewportDomBufferMultiplier"; "required": false; }; "PreViewportDomBufferMultiplier": { "alias": "PreViewportDomBufferMultiplier"; "required": false; }; "PreViewportTriggerLoadBufferMultiplier": { "alias": "PreViewportTriggerLoadBufferMultiplier"; "required": false; }; "PreViewportLoadBufferMultiplier": { "alias": "PreViewportLoadBufferMultiplier"; "required": false; }; "ScrollDirectionChangeThreshold": { "alias": "ScrollDirectionChangeThreshold"; "required": false; }; "spaceBetweenImages": { "alias": "spaceBetweenImages"; "required": false; }; "thumbnailSize": { "alias": "thumbnailSize"; "required": false; }; "withImageClickEvents": { "alias": "withImageClickEvents"; "required": false; }; "datastore": { "alias": "datastore"; "required": true; }; "urlForImage": { "alias": "urlForImage"; "required": true; }; "urlForThumbnail": { "alias": "urlForThumbnail"; "required": false; }; "createMigImage": { "alias": "createMigImage"; "required": false; }; "getMinAspectRatio": { "alias": "getMinAspectRatio"; "required": false; }; "getImageSize": { "alias": "getImageSize"; "required": false; }; }, { "numberOfImagesOnServer": "numberOfImagesOnServer"; "numberOfImagesOnServerFiltered": "numberOfImagesOnServerFiltered"; "imageClicked": "imageClicked"; }, never, never, true, never>; }