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

Commit 939ac7a

Browse files
marhijkuri
authored andcommitted
fix(): fixed style flickering (closes #71)
1 parent ec5ab06 commit 939ac7a

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

e2e/app.e2e.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,5 +464,10 @@ describe('bterm launch', function() {
464464
});
465465
}
466466

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

473+
});

src/app/components/window-top/window-top.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class WindowTopComponent implements OnInit {
145145
return([ mm.screenX - startX, mm.screenY - startY ]);
146146
}
147147
)
148-
.filter(x => x[0] != 0 || x[1] != 0)
148+
.filter(x => x[0] !== 0 || x[1] !== 0)
149149
.takeUntil(mouseUp$)
150150
}
151151
)

src/utils.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ export class CssBuilder {
8787
return this.css;
8888
}
8989

90-
inject(): void {
90+
inject(seamless: boolean = true): void {
9191
this.build();
92-
if (this.styleEl) { this.styleEl.remove(); }
92+
if (!seamless && this.styleEl) { this.styleEl.remove(); }
9393

94-
this.styleEl = document.createElement('style') as HTMLStyleElement;
95-
this.styleEl.setAttribute('type', 'text/css');
96-
this.styleEl.innerHTML = this.css;
94+
let newStyle: HTMLStyleElement = document.createElement('style') as HTMLStyleElement;
95+
newStyle.setAttribute('type', 'text/css');
96+
newStyle.innerHTML = this.css;
9797

98-
setTimeout(() => document.querySelector('head').appendChild(this.styleEl));
98+
document.querySelector('head').appendChild(newStyle);
99+
if (this.styleEl) { this.styleEl.remove(); }
100+
this.styleEl = newStyle;
99101
}
100102
}

0 commit comments

Comments
 (0)