Skip to content

Commit 292183c

Browse files
committed
conditional log list component
1 parent 4aefd2d commit 292183c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/js/components/list/element-list.component.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,15 @@ export class ElementListComponent {
7676
this.stepsCount = 1;
7777
}
7878

79+
log = false;
80+
7981
private draw($elementList: Element[], $animate = false) {
8082
let element: Element;
8183
const elementsToDisplay: Element[] = $elementList.filter((el) => el.isFullyLoaded);
8284

8385
this.elementToDisplayCount = elementsToDisplay.length;
84-
console.log('-------------');
85-
console.log('ElementList draw', elementsToDisplay.length);
86+
if (this.log) console.log('-------------');
87+
if (this.log) console.log('ElementList draw', elementsToDisplay.length);
8688

8789
if (App.dataType == AppDataType.All) {
8890
for (element of elementsToDisplay) element.updateDistance();
@@ -97,9 +99,9 @@ export class ElementListComponent {
9799

98100
// If new elements to display are different than the visible one, draw them
99101
const newIdsToDisplay = elementsToDisplay.map((el) => el.id);
100-
console.log('Already Visible elements', this.visibleElementIds, 'new elements length', newIdsToDisplay.length);
102+
if (this.log) console.log('Already Visible elements', this.visibleElementIds, 'new elements length', newIdsToDisplay.length);
101103
if (newIdsToDisplay.length >= maxElementsToDisplay && arraysEqual(newIdsToDisplay, this.visibleElementIds)) {
102-
console.log('nothing to draw');
104+
if (this.log) console.log('nothing to draw');
103105
return;
104106
}
105107

@@ -110,7 +112,7 @@ export class ElementListComponent {
110112
if (newIdsToDisplay[i] !== this.visibleElementIds[i]) newElementsToDisplayIncludesPerfectlyOldOnes = false;
111113
}
112114
}
113-
console.log('newElementsToDisplayIncludesPerfectlyOldOnes', newElementsToDisplayIncludesPerfectlyOldOnes);
115+
if (this.log) console.log('newElementsToDisplayIncludesPerfectlyOldOnes', newElementsToDisplayIncludesPerfectlyOldOnes);
114116

115117
let startIndex,
116118
endIndex = Math.min(maxElementsToDisplay, elementsToDisplay.length);
@@ -124,7 +126,7 @@ export class ElementListComponent {
124126
const listContentDom = $('#directory-content-list ul.collapsible');
125127
const that = this;
126128

127-
console.log('startIndex', startIndex, 'endIndex', endIndex);
129+
if (this.log) console.log('startIndex', startIndex, 'endIndex', endIndex);
128130
for (let i = startIndex; i < endIndex; i++) {
129131
element = elementsToDisplay[i];
130132
this.visibleElementIds.push(element.id);
@@ -142,7 +144,7 @@ export class ElementListComponent {
142144
if (elementsToDisplay.length < maxElementsToDisplay) {
143145
if (App.dataType == AppDataType.All) {
144146
// expand bounds
145-
console.log('not enugh elements, expand bounds');
147+
if (this.log) console.log('not enugh elements, expand bounds');
146148
if (App.boundsModule.extendBounds(0.5)) {
147149
this.showSpinnerLoader();
148150
App.elementsManager.checkForNewElementsToRetrieve(true);
@@ -151,7 +153,7 @@ export class ElementListComponent {
151153
}
152154
}
153155
} else {
154-
// console.log("list is full");
156+
if (this.log) console.log("list is full");
155157
// waiting for scroll bottom to add more elements to the list
156158
this.isListFull = true;
157159
}
@@ -234,7 +236,7 @@ export class ElementListComponent {
234236
private handleBottom() {
235237
if (this.isListFull) {
236238
this.stepsCount++;
237-
console.log('bottom reached');
239+
if (this.log) console.log('bottom reached');
238240
this.isListFull = false;
239241
this.draw(App.elements());
240242
}

0 commit comments

Comments
 (0)