Skip to content

Commit

Permalink
fix indexes bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mb925 committed Mar 22, 2022
1 parent 766b6e5 commit 3bcadd9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
21 changes: 9 additions & 12 deletions dist/sqv-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ class ProSeqViewer {
let labelsContainer = '';
const noGapsLabels = [];
if (labels.length > 0) {
if (indexesLocation == 'top' || 'both') {
if (indexesLocation != 'lateral') {
labelshtml += `<span class="lbl-hidden" style="margin-bottom:${lineSeparation};"></span>`;
}
let flag;
Expand Down Expand Up @@ -1250,7 +1250,7 @@ class ProSeqViewer {
let idx;
let cells = '';
for (let x = 1; x <= maxIdx; x++) {
if (indexesLocation == 'top' || 'both') {
if (indexesLocation != 'lateral') {
cells = this.addTopIndexes(chunkSize, x, maxTop, lineSeparation);
}
;
Expand Down Expand Up @@ -1285,7 +1285,7 @@ class ProSeqViewer {
cells = '';
if (chunkSize > 0 && x % chunkSize === 0) {
// considering the row of top indexes
if (indexesLocation != 'top' || 'both') {
if (indexesLocation != 'top') {
idxNum += chunkSize; // lateral index (set only if top indexes missing)
idx = idxNum - (chunkSize - 1);
// adding labels
Expand All @@ -1300,16 +1300,13 @@ class ProSeqViewer {
index = gapsContainer; // lateral number indexes
}
else {
if (indexesLocation == 'lateral' || 'both') {
index = labelsContainer + gapsContainer; // lateral number indexes + labels
}
else {
index = labelsContainer; // lateral number indexes + labels
}
// if(indexesLocation == 'both'){
index = labelsContainer + gapsContainer; // lateral number indexes + labels
// }
}
}
else {
index = labelsContainer;
index = labelsContainer; // top
}
index = `<div class="idx hidden">${index}</div>`;
style = `font-size: ${fontSize};`;
Expand All @@ -1320,11 +1317,11 @@ class ProSeqViewer {
style += 'margin-right: ' + chunkSeparation + 'em;';
}
let chunk = '';
if (labelsFlag || options.consensusType || indexesLocation == 'lateral' || indexesLocation == 'both') {
if (labelsFlag || options.consensusType || indexesLocation == 'both' || indexesLocation == 'lateral') { // both
chunk = `<div class="cnk" style="${style}">${index}<div class="crds">${cards}</div></div>`;
}
else {
chunk = `<div class="cnk" style="${style}"><div class="idx hidden"></div><div class="crds">${cards}</div></div>`;
chunk = `<div class="cnk" style="${style}"><div class="idx hidden"></div><div class="crds">${cards}</div></div>`; // top
}
cards = '';
index = '';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "proseqviewer",
"version": "1.1.7",
"version": "1.1.9",
"main": "index.js",
"types": "index.d.ts",
"repository": {
Expand Down
16 changes: 6 additions & 10 deletions src/lib/proseqviewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class ProSeqViewer {
const noGapsLabels = [];

if (labels.length > 0) {
if (indexesLocation == 'top' || 'both') {
if (indexesLocation != 'lateral') {
labelshtml += `<span class="lbl-hidden" style="margin-bottom:${lineSeparation};"></span>`;
}
let flag;
Expand Down Expand Up @@ -285,7 +285,7 @@ export class ProSeqViewer {
let idx;
let cells = '';
for (let x = 1; x <= maxIdx; x++) {
if (indexesLocation == 'top' || 'both') {cells = this.addTopIndexes(chunkSize, x, maxTop, lineSeparation)};
if (indexesLocation != 'lateral') {cells = this.addTopIndexes(chunkSize, x, maxTop, lineSeparation)};

for (let y = 0; y < data.length; y++) {
entity = data[y][x];
Expand Down Expand Up @@ -316,7 +316,7 @@ export class ProSeqViewer {

if (chunkSize > 0 && x % chunkSize === 0) {
// considering the row of top indexes
if (indexesLocation != 'top' || 'both') {
if (indexesLocation != 'top') {
idxNum += chunkSize; // lateral index (set only if top indexes missing)
idx = idxNum - (chunkSize - 1);
// adding labels
Expand All @@ -332,14 +332,10 @@ export class ProSeqViewer {
if (!labelsFlag) {
index = gapsContainer; // lateral number indexes
} else {
if(indexesLocation == 'lateral' || 'both'){
index = labelsContainer + gapsContainer; // lateral number indexes + labels
} else {
index = labelsContainer; // lateral number indexes + labels
}
}
} else {
index = labelsContainer;
index = labelsContainer; // top
}

index = `<div class="idx hidden">${index}</div>`;
Expand All @@ -349,10 +345,10 @@ export class ProSeqViewer {

let chunk = '';

if (labelsFlag || options.consensusType || indexesLocation == 'lateral' || indexesLocation == 'both') {
if (labelsFlag || options.consensusType || indexesLocation == 'both' || indexesLocation == 'lateral') { // both
chunk = `<div class="cnk" style="${style}">${index}<div class="crds">${cards}</div></div>`;
} else {
chunk = `<div class="cnk" style="${style}"><div class="idx hidden"></div><div class="crds">${cards}</div></div>`;
chunk = `<div class="cnk" style="${style}"><div class="idx hidden"></div><div class="crds">${cards}</div></div>`; // top
}
cards = '';
index = '';
Expand Down

0 comments on commit 3bcadd9

Please sign in to comment.