Skip to content

Commit

Permalink
Fixing issue with table not resizing correctly after updating it
Browse files Browse the repository at this point in the history
  • Loading branch information
ultrakorne committed Jun 17, 2020
1 parent c44a145 commit bbc370d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "better-rolltables",
"title": "Better Roll Tables",
"description": "Adding functionality to roll tables, especially to roll treasure and magic items",
"version": "1.1.1",
"version": "1.1.2",
"author": "Ultrakorne#6240",
"esmodules": [
"./scripts/brt-main.js"
Expand Down Expand Up @@ -40,5 +40,5 @@
],
"url": "https://github.com/ultrakorne/better-rolltables",
"manifest": "https://raw.githubusercontent.com/ultrakorne/better-rolltables/master/module.json",
"download": "https://github.com/ultrakorne/better-rolltables/releases/download/v1.1.1/better-rolltables.zip"
"download": "https://github.com/ultrakorne/better-rolltables/releases/download/v1.1.2/better-rolltables.zip"
}
41 changes: 14 additions & 27 deletions scripts/better-table-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,21 @@ export class BetterRT {
const tableEntity = rollTableConfig.object;
const selectedTableType = tableEntity.getFlag(BRTCONFIG.NAMESPACE, BRTCONFIG.TABLE_TYPE_KEY) || BRTCONFIG.TABLE_TYPE_NONE;

let tableViewClass = html[0].getElementsByClassName(tableClassName)[0];

//re-renders, without this the view has a scroll bar and its not sized correctly
if (tableViewClass) {
/**
* height size increase by type:
* default 28
* better 55
* loot 80
* story 28
*/
let addHeight = 0;
if(selectedTableType === BRTCONFIG.TABLE_TYPE_LOOT) addHeight = 80;
else addHeight = 28;

const match = html[0].style.height.match(/\d+/);
const height = match[0];
html[0].style.height = (+height + addHeight) + "px";
const tableElement = document.getElementById(`app-${rollTableConfig.appId}`);
let tableViewClass = tableElement.getElementsByClassName(tableClassName)[0];

/** height size increase by type: */
let addHeight = 0;
switch (selectedTableType) {
case BRTCONFIG.TABLE_TYPE_LOOT:
addHeight = 80;
break;
default:
addHeight = 28;
}

if (!tableViewClass) { //when the table is updated, the html is different
if (html[0].getAttribute("class") === tableClassName) {
tableViewClass = html[0];
} else {
console.log(`cannot find table class element ${tableClassName}`);
}
}
// console.log("tableViewClass html ", tableViewClass);
const match = tableElement.style.height.match(/\d+/);
const height = match[0];
tableElement.style.height = (+height + addHeight) + "px";

let divElement = document.createElement("div");
let brtData = duplicate(tableEntity.data.flags);
Expand Down

0 comments on commit bbc370d

Please sign in to comment.