Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
fix(): fixed style flickering (closes #71)
Browse files Browse the repository at this point in the history
  • Loading branch information
marhi authored and jkuri committed May 19, 2017
1 parent ec5ab06 commit 939ac7a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
7 changes: 6 additions & 1 deletion e2e/app.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,5 +464,10 @@ describe('bterm launch', function() {
});
}

})
it('should inject a style element into head', () => {
return this.app.client.waitUntilWindowLoaded()
.then(() => this.app.client.elements('head style'))
.then(result => expect(result.value.length).to.equal(1));
});

});
2 changes: 1 addition & 1 deletion src/app/components/window-top/window-top.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class WindowTopComponent implements OnInit {
return([ mm.screenX - startX, mm.screenY - startY ]);
}
)
.filter(x => x[0] != 0 || x[1] != 0)
.filter(x => x[0] !== 0 || x[1] !== 0)
.takeUntil(mouseUp$)
}
)
Expand Down
14 changes: 8 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ export class CssBuilder {
return this.css;
}

inject(): void {
inject(seamless: boolean = true): void {
this.build();
if (this.styleEl) { this.styleEl.remove(); }
if (!seamless && this.styleEl) { this.styleEl.remove(); }

this.styleEl = document.createElement('style') as HTMLStyleElement;
this.styleEl.setAttribute('type', 'text/css');
this.styleEl.innerHTML = this.css;
let newStyle: HTMLStyleElement = document.createElement('style') as HTMLStyleElement;
newStyle.setAttribute('type', 'text/css');
newStyle.innerHTML = this.css;

setTimeout(() => document.querySelector('head').appendChild(this.styleEl));
document.querySelector('head').appendChild(newStyle);
if (this.styleEl) { this.styleEl.remove(); }
this.styleEl = newStyle;
}
}

0 comments on commit 939ac7a

Please sign in to comment.