fixing IE scroll error

This commit is contained in:
Patrik J. Braun 2018-05-09 13:56:02 -04:00
parent 44cde498ea
commit 23679aeb8f
10 changed files with 53 additions and 30 deletions

View File

@ -19,19 +19,18 @@ export class GalleryMWs {
public static async listDirectory(req: Request, res: Response, next: NextFunction) {
console.log('listDirectory');
let directoryName = req.params.directory || '/';
let absoluteDirectoryName = path.join(ProjectPath.ImageFolder, directoryName);
const directoryName = req.params.directory || '/';
const absoluteDirectoryName = path.join(ProjectPath.ImageFolder, directoryName);
if (!fs.statSync(absoluteDirectoryName).isDirectory()) {
console.log('not dir');
return next();
}
try {
const directory = await ObjectManagerRepository.getInstance()
.GalleryManager.listDirectory(directoryName, req.query.knownLastModified, req.query.knownLastScanned);
const directory = await ObjectManagerRepository.getInstance().GalleryManager.listDirectory(directoryName, req.query.knownLastModified, req.query.knownLastScanned);
if (directory == null) {
console.log('null dir');
req.resultPipe = new ContentWrapper(null, null, true);
return next();
}
@ -39,7 +38,7 @@ export class GalleryMWs {
console.log(directory);
if (req.session.user.permissions &&
req.session.user.permissions.length > 0 &&
req.session.user.permissions[0] != '/*') {
req.session.user.permissions[0] !== '/*') {
(<DirectoryDTO>directory).directories = (<DirectoryDTO>directory).directories.filter(d =>
UserDTO.isDirectoryAvailable(d, req.session.user.permissions));
}
@ -53,14 +52,15 @@ export class GalleryMWs {
public static removeCyclicDirectoryReferences(req: Request, res: Response, next: NextFunction) {
if (!req.resultPipe)
return next();
let cw: ContentWrapper = req.resultPipe;
if (cw.notModified == true) {
if (!req.resultPipe) {
return next();
}
let removeDirs = (dir) => {
const cw: ContentWrapper = req.resultPipe;
if (cw.notModified === true) {
return next();
}
const removeDirs = (dir) => {
dir.photos.forEach((photo: PhotoDTO) => {
photo.directory = null;
});
@ -86,9 +86,9 @@ export class GalleryMWs {
return next();
}
let fullImagePath = path.join(ProjectPath.ImageFolder, req.params.imagePath);
const fullImagePath = path.join(ProjectPath.ImageFolder, req.params.imagePath);
//check if thumbnail already exist
// check if thumbnail already exist
if (fs.existsSync(fullImagePath) === false) {
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'no such file:' + fullImagePath));
}
@ -113,7 +113,7 @@ export class GalleryMWs {
let type: SearchTypes;
if (req.query.type) {
type = parseInt(req.query.type);
type = parseInt(req.query.type, 10);
}
try {
const result = await ObjectManagerRepository.getInstance().SearchManager.search(req.params.text, type);

View File

@ -28,7 +28,6 @@ export class UserManager implements IUserManager {
}
if (!this.db.idCounter) {
console.log('creating counter');
this.db.idCounter = 1;
}

View File

@ -94,7 +94,6 @@ declare const require;
export function translationsFactory(locale: string) {
locale = locale || 'en'; // default to english if no locale
console.log('locale', locale);
return require(`raw-loader!../translate/messages.${locale}.xlf`);
}

View File

@ -6,6 +6,7 @@ import {Utils} from '../../../../common/Utils';
import {Photo} from '../Photo';
import {Thumbnail, ThumbnailManagerService} from '../thumnailManager.service';
import {ShareService} from '../share.service';
import {PageHelper} from '../../model/page.helper';
@Component({
selector: 'app-gallery-directory',
@ -53,9 +54,8 @@ export class GalleryDirectoryComponent implements OnInit, OnDestroy {
}
calcSize() {
if (this.size == null ||
document.getElementsByTagName('body')[0].style.overflowY == 'scroll') {
let size = 220 + 5;
if (this.size == null || PageHelper.isScrollYVisible()) {
const size = 220 + 5;
const containerWidth = this.container.nativeElement.parentElement.parentElement.clientWidth;
this.size = containerWidth / Math.round((containerWidth / size));
}

View File

@ -13,6 +13,7 @@ import {NavigationService} from '../model/navigation.service';
import {UserRoles} from '../../../common/entities/UserDTO';
import {interval} from 'rxjs/observable/interval';
import {ContentWrapper} from '../../../common/entities/ConentWrapper';
import {PageHelper} from '../model/page.helper';
@Component({
selector: 'gallery',
@ -45,8 +46,7 @@ export class GalleryComponent implements OnInit, OnDestroy {
private _navigation: NavigationService) {
this.mapEnabled = Config.Client.Map.enabled;
document.getElementsByTagName('body')[0].style.overflowY = 'scroll';
PageHelper.showScrollY();
}
updateTimer(t: number) {

View File

@ -18,6 +18,7 @@ import {GridPhoto} from './GridPhoto';
import {GalleryPhotoComponent} from './photo/photo.grid.gallery.component';
import {OverlayService} from '../overlay.service';
import {Config} from '../../../../common/config/public/Config';
import {PageHelper} from '../../model/page.helper';
@Component({
selector: 'app-gallery-grid',
@ -177,7 +178,7 @@ export class GalleryGridComponent implements OnChanges, AfterViewInit, OnDestroy
*/
private shouldRenderMore(offset: number = 0): boolean {
return Config.Client.enableOnScrollRendering === false ||
window.scrollY >= (document.body.clientHeight + offset - window.innerHeight) * 0.7
PageHelper.ScrollY >= (document.body.clientHeight + offset - window.innerHeight) * 0.7
|| (document.body.clientHeight + offset) * 0.85 < window.innerHeight;
}

View File

@ -6,6 +6,7 @@ import {AgmMap} from '@agm/core';
import {IconThumbnail, Thumbnail, ThumbnailManagerService} from '../../thumnailManager.service';
import {IconPhoto} from '../../IconPhoto';
import {Photo} from '../../Photo';
import {PageHelper} from '../../../model/page.helper';
@Component({
selector: 'app-gallery-map-lightbox',
@ -55,7 +56,7 @@ export class GalleryMapLightboxComponent implements OnChanges {
};
this.map.triggerResize();
document.getElementsByTagName('body')[0].style.overflowY = 'hidden';
PageHelper.hideScrollY();
setTimeout(() => {
this.lightboxDimension = <Dimension>{
@ -79,7 +80,7 @@ export class GalleryMapLightboxComponent implements OnChanges {
this.lightboxDimension = this.startPosition;
this.lightboxDimension.top -= this.getBodyScrollTop();
document.getElementsByTagName('body')[0].style.overflowY = 'scroll';
PageHelper.showScrollY();
this.opacity = 0.0;
setTimeout(() => {
this.visible = false;

View File

@ -1,5 +1,6 @@
import {Injectable} from '@angular/core';
import {Event} from '../../../common/event/Event';
import {PageHelper} from '../model/page.helper';
@Injectable()
export class OverlayService {
@ -9,12 +10,12 @@ export class OverlayService {
public showOverlay() {
// disable scrolling
document.getElementsByTagName('body')[0].style.overflowY = 'hidden';
PageHelper.hideScrollY();
this.OnOverlayChange.trigger(true);
}
public hideOverlay() {
document.getElementsByTagName('body')[0].style.overflowY = 'scroll';
PageHelper.showScrollY();
this.OnOverlayChange.trigger(false);
}
@ -47,7 +48,7 @@ export class OverlayService {
}
getPhantomScrollbarWidth() {
if (document.getElementsByTagName('body')[0].style.overflowY === 'hidden') {
if (!PageHelper.isScrollYVisible()) {
return this.getScrollbarWidth();
}
return 0;

View File

@ -17,7 +17,6 @@ export class NavigationService {
}
public async toLogin() {
console.log('toLogin');
await this._shareService.wait();
if (this._shareService.isSharing()) {
return this._router.navigate(['shareLogin'], {queryParams: {sk: this._shareService.getSharingKey()}});
@ -27,7 +26,6 @@ export class NavigationService {
}
public async toGallery() {
console.log('toGallery');
await this._shareService.wait();
if (this._shareService.isSharing()) {
return this._router.navigate(['gallery', ''], {queryParams: {sk: this._shareService.getSharingKey()}});

View File

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