igniteui-angular-sovn
Version:
Ignite UI for Angular is a dependency-free Angular toolkit for building modern web apps
64 lines (54 loc) • 1.66 kB
text/typescript
import { Injectable } from '@angular/core';
import { IgxGridForOfDirective } from './for_of.directive';
import { VirtualHelperBaseDirective } from './base.helper.component';
({
providedIn: 'root',
})
export class IgxForOfSyncService {
private _master: Map<string, IgxGridForOfDirective<any, any[]>> = new Map<string, IgxGridForOfDirective<any, any[]>>();
/**
* @hidden
*/
public isMaster(directive: IgxGridForOfDirective<any, any[]>): boolean {
return this._master.get(directive.igxForScrollOrientation) === directive;
}
/**
* @hidden
*/
public setMaster(directive: IgxGridForOfDirective<any, any[]>, 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;
}
}
({
providedIn: 'root',
})
export class IgxForOfScrollSyncService {
private _masterScroll: Map<string, VirtualHelperBaseDirective> = new Map<string, any>();
public setScrollMaster(dir: string, scroll: VirtualHelperBaseDirective) {
this._masterScroll.set(dir, scroll);
}
public getScrollMaster(dir: string) {
return this._masterScroll.get(dir);
}
}