2018-05-09 13:56:02 -04:00
|
|
|
export class PageHelper {
|
|
|
|
private static readonly supportPageOffset = window.pageXOffset !== undefined;
|
|
|
|
private static readonly isCSS1Compat = ((document.compatMode || '') === 'CSS1Compat');
|
2018-05-16 18:52:08 -04:00
|
|
|
private static readonly body = document.getElementsByTagName('body')[0];
|
2018-05-09 13:56:02 -04:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static get ScrollY(): number {
|
|
|
|
return this.supportPageOffset ? window.pageYOffset : this.isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;
|
|
|
|
}
|
|
|
|
|
2018-05-26 20:49:55 -04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-05-09 13:56:02 -04:00
|
|
|
public static showScrollY() {
|
2018-05-16 18:52:08 -04:00
|
|
|
PageHelper.body.style.overflowY = 'scroll';
|
2018-05-09 13:56:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public static isScrollYVisible(): boolean {
|
2018-05-16 18:52:08 -04:00
|
|
|
return PageHelper.body.style.overflowY === 'scroll';
|
2018-05-09 13:56:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public static hideScrollY() {
|
2018-05-16 18:52:08 -04:00
|
|
|
PageHelper.body.style.overflowY = 'hidden';
|
2018-05-09 13:56:02 -04:00
|
|
|
}
|
|
|
|
}
|