Navigation Menu

Skip to content

Commit

Permalink
make replace all rows replace all dom rows
Browse files Browse the repository at this point in the history
  • Loading branch information
krausest committed Jan 9, 2017
1 parent 3d58e6b commit 93c57f7
Showing 1 changed file with 8 additions and 29 deletions.
37 changes: 8 additions & 29 deletions vanillajs-keyed/src/Main.js
Expand Up @@ -189,8 +189,11 @@ class Main {
}
run() {
startMeasure("run");
this.removeAllRows();
this.store.clear();
this.rows = [];
this.data = [];
this.store.run();
this.updateRows();
this.appendRows();
this.unselect();
stopMeasure();
Expand All @@ -204,7 +207,6 @@ class Main {
update() {
startMeasure("update");
this.store.update();
// this.updateRows();
for (let i=0;i<this.data.length;i+=10) {
this.rows[i].childNodes[1].childNodes[0].innerText = this.store.data[i].label;
}
Expand Down Expand Up @@ -243,34 +245,8 @@ class Main {
this.unselect();

this.recreateSelection();

// Faster, shift all rows below the row that should be deleted rows one up and drop the last row
// for(let i=this.rows.length-2; i>=idx;i--) {
// let tr = this.rows[i];
// let data = this.store.data[i+1];
// tr.data_id = data.id;
// tr.childNodes[0].innerText = data.id;
// tr.childNodes[1].childNodes[0].innerText = data.label;
// this.data[i] = this.store.data[i];
// }
// this.store.delete(this.data[idx].id);
// this.data.splice(idx, 1);
// this.rows.pop().remove();

stopMeasure();
}
updateRows() {
for(let i=0;i<this.rows.length;i++) {
if (this.data[i] !== this.store.data[i]) {
let tr = this.rows[i];
let data = this.store.data[i];
tr.data_id = data.id;
tr.childNodes[0].innerText = data.id;
tr.childNodes[1].childNodes[0].innerText = data.label;
this.data[i] = this.store.data[i];
}
}
}
removeAllRows() {
// ~258 msecs
// for(let i=this.rows.length-1;i>=0;i--) {
Expand All @@ -296,8 +272,11 @@ class Main {
}
runLots() {
startMeasure("runLots");
this.removeAllRows();
this.store.clear();
this.rows = [];
this.data = [];
this.store.runLots();
this.updateRows();
this.appendRows();
this.unselect();
stopMeasure();
Expand Down

0 comments on commit 93c57f7

Please sign in to comment.