Skip to content

Commit 256dc82

Browse files
committed
Fix problem with initial set-up of sequence editor when not initially attached to DOM.
1 parent 4dd35e0 commit 256dc82

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

src/app/widgets/ks-sequence-editor/ks-sequence-editor.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ div {
55
}
66

77
canvas {
8+
box-sizing: content-box !important;
89
font-family: Verdana, Geneva, sans-serif;
910
font-size: 12px;
1011
border: 1px solid #D8D8D8;

src/app/widgets/ks-sequence-editor/ks-sequence-editor.component.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export class KsSequenceEditorComponent implements AfterViewInit, OnInit, OnDestr
119119
protected items: SequenceItemInfo[] = [];
120120
protected hasFocus = false;
121121
protected selection = 0;
122+
protected setupComplete = false;
122123

123124
public displayState = 'normal';
124125

@@ -183,6 +184,23 @@ export class KsSequenceEditorComponent implements AfterViewInit, OnInit, OnDestr
183184

184185
ngAfterViewInit(): void {
185186
this.canvas = this.canvasRef.nativeElement;
187+
188+
if (document.body.contains(this.canvas))
189+
this.setup();
190+
else {
191+
const observer = new MutationObserver(() => {
192+
if (document.body.contains(this.canvas)) {
193+
observer.disconnect();
194+
this.setup();
195+
}
196+
});
197+
198+
observer.observe(document.body, {childList: true, subtree: true});
199+
}
200+
}
201+
202+
private setup(): void {
203+
this.canvas = this.canvasRef.nativeElement;
186204
this.font = getFont(this.canvas);
187205

188206
this.smallFont = this.fixedFont = this.smallFixedFont = this.font;
@@ -233,6 +251,7 @@ export class KsSequenceEditorComponent implements AfterViewInit, OnInit, OnDestr
233251
this.canvas.contentEditable = 'false';
234252

235253
this.computeSize();
254+
this.setupComplete = true;
236255
this.draw();
237256
}
238257

@@ -310,7 +329,7 @@ export class KsSequenceEditorComponent implements AfterViewInit, OnInit, OnDestr
310329
}
311330

312331
protected draw(): void {
313-
if (!this.canvas)
332+
if (!this.canvas || !this.setupComplete)
314333
return;
315334

316335
const padding = KsSequenceEditorComponent.getPadding(this.metrics);

src/assets/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<h2 class="header-sans"><a name="history">What's New / Version History</a></h2>
6161
<div style="padding-left: 1em; text-indent: -1em">
6262

63-
<p><b>1.5.0, 2019-04-16:</b> Updated GRS data and UTC conversion, made changes needed for full functionality
63+
<p><b>1.5.0, 2019-04-18:</b> Updated GRS data and UTC conversion, made changes needed for full functionality
6464
via HTTPS.</p>
6565

6666
<p><b>1.4.14, 2018-08-14:</b> Added quick drawing mode for Orbits view. Added speed metrics.</p>

tslint.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@
4949
"object-literal-sort-keys": false,
5050
"one-line": [
5151
true,
52-
//"check-open-brace",
53-
//"check-catch",
54-
//"check-else",
5552
"check-whitespace"
5653
],
5754
"quotemark": [

0 commit comments

Comments
 (0)