Rewrote weightDelta calculation to be more readable based on PR feedback
Brian Vaughn committed
Apr 10, 2019 at 08:59 UTC
74c9904e5d520662cc9c29f8b760818c77b537a3
1 file changed
+3
-2
src/devtools/store.js
+3
-2
@@ -430,9 +430,10 @@ export default class Store extends EventEmitter {
430
toggleIsCollapsed(id: number, isCollapsed: boolean): void {
431
const element = this.getElementByID(id);
432
if (element !== null) {
433
+ const oldWeight = element.isCollapsed ? 1 : element.weight;
434
element.isCollapsed = isCollapsed;
434
-
435
- const weightDelta = isCollapsed ? 1 - element.weight : element.weight - 1;
435
+ const newWeight = element.isCollapsed ? 1 : element.weight;
436
+ const weightDelta = newWeight - oldWeight;
437
438
this._weightAcrossRoots += weightDelta;
439