Skip to content

Commit

Permalink
Fix problem with initial set-up of sequence editor when not initially…
Browse files Browse the repository at this point in the history
… attached to DOM.
  • Loading branch information
kshetline committed Apr 18, 2019
1 parent 4dd35e0 commit 256dc82
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ div {
}

canvas {
box-sizing: content-box !important;
font-family: Verdana, Geneva, sans-serif;
font-size: 12px;
border: 1px solid #D8D8D8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class KsSequenceEditorComponent implements AfterViewInit, OnInit, OnDestr
protected items: SequenceItemInfo[] = [];
protected hasFocus = false;
protected selection = 0;
protected setupComplete = false;

public displayState = 'normal';

Expand Down Expand Up @@ -183,6 +184,23 @@ export class KsSequenceEditorComponent implements AfterViewInit, OnInit, OnDestr

ngAfterViewInit(): void {
this.canvas = this.canvasRef.nativeElement;

if (document.body.contains(this.canvas))
this.setup();
else {
const observer = new MutationObserver(() => {
if (document.body.contains(this.canvas)) {
observer.disconnect();
this.setup();
}
});

observer.observe(document.body, {childList: true, subtree: true});
}
}

private setup(): void {
this.canvas = this.canvasRef.nativeElement;
this.font = getFont(this.canvas);

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

this.computeSize();
this.setupComplete = true;
this.draw();
}

Expand Down Expand Up @@ -310,7 +329,7 @@ export class KsSequenceEditorComponent implements AfterViewInit, OnInit, OnDestr
}

protected draw(): void {
if (!this.canvas)
if (!this.canvas || !this.setupComplete)
return;

const padding = KsSequenceEditorComponent.getPadding(this.metrics);
Expand Down
2 changes: 1 addition & 1 deletion src/assets/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<h2 class="header-sans"><a name="history">What's New / Version History</a></h2>
<div style="padding-left: 1em; text-indent: -1em">

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

<p><b>1.4.14, 2018-08-14:</b> Added quick drawing mode for Orbits view. Added speed metrics.</p>
Expand Down
3 changes: 0 additions & 3 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
"object-literal-sort-keys": false,
"one-line": [
true,
//"check-open-brace",
//"check-catch",
//"check-else",
"check-whitespace"
],
"quotemark": [
Expand Down

0 comments on commit 256dc82

Please sign in to comment.