1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/frontend/app/model/page.helper.ts
2018-05-26 20:49:55 -04:00

34 lines
1.0 KiB
TypeScript

export class PageHelper {
private static readonly supportPageOffset = window.pageXOffset !== undefined;
private static readonly isCSS1Compat = ((document.compatMode || '') === 'CSS1Compat');
private static readonly body = document.getElementsByTagName('body')[0];
constructor() {
}
public static get ScrollY(): number {
return this.supportPageOffset ? window.pageYOffset : this.isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;
}
public static get ScrollX(): number {
return this.supportPageOffset ? window.pageXOffset : this.isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft;
}
public static set ScrollY(value: number) {
window.scrollTo(this.ScrollX, value);
}
public static showScrollY() {
PageHelper.body.style.overflowY = 'scroll';
}
public static isScrollYVisible(): boolean {
return PageHelper.body.style.overflowY === 'scroll';
}
public static hideScrollY() {
PageHelper.body.style.overflowY = 'hidden';
}
}