import { Injectable } from '@angular/core'; import { IgxGridForOfDirective } from './for_of.directive'; import { VirtualHelperBaseDirective } from './base.helper.component'; @Injectable({ providedIn: 'root', }) export class IgxForOfSyncService { private _master: Map> = new Map>(); /** * @hidden */ public isMaster(directive: IgxGridForOfDirective): boolean { return this._master.get(directive.igxForScrollOrientation) === directive; } /** * @hidden */ public setMaster(directive: IgxGridForOfDirective, forced = false) { const orientation = directive.igxForScrollOrientation; if (orientation && (forced || !this._master.has(orientation))) { this._master.set(orientation, directive); } } /** * @hidden */ public resetMaster() { this._master.clear(); } /** * @hidden */ public sizesCache(dir: string): number[] { return this._master.get(dir).sizesCache; } /** * @hidden */ public chunkSize(dir: string): number { return this._master.get(dir).state.chunkSize; } } @Injectable({ providedIn: 'root', }) export class IgxForOfScrollSyncService { private _masterScroll: Map = new Map(); public setScrollMaster(dir: string, scroll: VirtualHelperBaseDirective) { this._masterScroll.set(dir, scroll); } public getScrollMaster(dir: string) { return this._masterScroll.get(dir); } }