Skip to content

Commit

Permalink
Add a configurable param for percentage of nodes hidden using display…
Browse files Browse the repository at this point in the history
…: none
  • Loading branch information
lpardosixtosMs committed Oct 19, 2023
1 parent 24c9751 commit 5d0ab55
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions resources/todomvc/big-dom-generator/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export const TARGET_SIZE = 6000;
// at least MIN_NUMBER_OF_MAX_DEPTH_BRANCHES of depth MAX_GENERATED_DOM_DEPTH.
export const MIN_NUMBER_OF_MAX_DEPTH_BRANCHES = 2;
export const MAX_VISIBLE_TREE_VIEW_ITEM_DEPTH = 8;
export const PERCENTAGE_OF_DISPLAY_NONE_TREEVIEW_ELEMENTS = 0.5;
4 changes: 2 additions & 2 deletions resources/todomvc/big-dom-generator/src/tree-generator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LCG } from "random-seedable";
import { DEFAULT_SEED_FOR_RANDOM_NUMBER_GENERATOR, MAX_GENERATED_DOM_DEPTH, MAX_NUMBER_OF_CHILDREN, PROBABILITY_OF_HAVING_CHILDREN, TARGET_SIZE, MIN_NUMBER_OF_MAX_DEPTH_BRANCHES } from "./../params";
import { DEFAULT_SEED_FOR_RANDOM_NUMBER_GENERATOR, MAX_GENERATED_DOM_DEPTH, MAX_NUMBER_OF_CHILDREN, PROBABILITY_OF_HAVING_CHILDREN, TARGET_SIZE, MIN_NUMBER_OF_MAX_DEPTH_BRANCHES, PERCENTAGE_OF_DISPLAY_NONE_TREEVIEW_ELEMENTS } from "./../params";

const random = new LCG(DEFAULT_SEED_FOR_RANDOM_NUMBER_GENERATOR);

Expand All @@ -16,7 +16,7 @@ const markDisplayNoneNodes = (node, expandableItemWeight, nonExpandableItemWeigh
let currentSubTreesWeights = node.subTreeWeight;
let currentIndex = 0;
let nodeQueue = [node];
while (currentSubTreesWeights >= TARGET_SIZE / 2) {
while (currentSubTreesWeights >= TARGET_SIZE * PERCENTAGE_OF_DISPLAY_NONE_TREEVIEW_ELEMENTS) {
const currentNode = nodeQueue[currentIndex];
nodeQueue[currentIndex] = null;
const expandableChildren = currentNode.children.filter((child) => child.type === "expandableItem");
Expand Down

0 comments on commit 5d0ab55

Please sign in to comment.