Commit 5ec07a05 by Tuukka Kivilahti

If user scrolls iframe, we remove it

1 parent 7d108edd
<iframe id="oldMoyaFrame" [src]="frameUrl | safe" [height]="height" #iframe (load)="changeUrl()" frameborder="0"></iframe>
<iframe id="oldMoyaFrame" [src]="frameUrl | safe" [height]="height" #iframe (load)="changeUrl()" frameborder="0" ></iframe>
import {map} from 'rxjs/operators';
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import {Component, OnInit, ViewChild, ElementRef, ApplicationRef, ChangeDetectorRef} from '@angular/core';
import {Location, LocationStrategy, HashLocationStrategy, PathLocationStrategy} from '@angular/common';
import {NavigationExtras, ActivatedRoute, Router} from '@angular/router';
import {angularCoreEnv} from "@angular/core/src/render3/jit/environment";
@Component({
selector: 'moya-old',
......@@ -22,10 +23,9 @@ export class OldMoyaComponent implements OnInit {
constructor(private location: Location, private route: ActivatedRoute) {
constructor(private location: Location, private route: ActivatedRoute, private changeDetectionRef: ChangeDetectorRef) {
route.queryParamMap.pipe(map(a => a.get('p'))).subscribe(x => {
console.log(x);
if (x) {
this.frameUrl = '/MoyaWeb/' + x.replace('::', '?');
}
......@@ -42,12 +42,18 @@ export class OldMoyaComponent implements OnInit {
this.location.replaceState(this.location.path(false).split('?', 1)[0] + '?p=' + tmpFrameUrl[1].replace('?', '::') );
}
this.iframe.nativeElement.contentWindow.onscroll = (() => {this.fixHeight(this)});
console.log(this.iframe.nativeElement.contentWindow.document.body.height);
this.height = (this.iframe.nativeElement.contentWindow.document.body.scrollHeight + 50) + 'px';
this.fixHeight(this);
}
fixHeight(self) {
console.log(self.iframe.nativeElement.contentWindow.document.body.scrollHeight);
if(self.height != (self.iframe.nativeElement.contentWindow.document.body.scrollHeight + 50) + 'px') {
self.height = (self.iframe.nativeElement.contentWindow.document.body.scrollHeight + 50) + 'px';
this.changeDetectionRef.detectChanges();
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!