Extracting custom event creation into a util module

This commit is contained in:
Jeff Avallone
2014-12-19 10:24:45 -05:00
parent 0d6e272216
commit 78917d44e6
6 changed files with 37 additions and 21 deletions
+3 -7
View File
@@ -1,3 +1,4 @@
import { customEvent } from '../../util.js';
import _ from 'lodash';
import Q from 'q';
@@ -108,20 +109,15 @@ export default class Node {
}
doneRender() {
var evt;
if (this.state.maxCounter === 0) {
this.state.maxCounter = this.state.renderCounter;
}
this.state.renderCounter--;
evt = document.createEvent('Event');
evt.initEvent('updateStatus', true, true);
evt.detail = {
document.body.dispatchEvent(customEvent('updateStatus', {
percentage: (this.state.maxCounter - this.state.renderCounter) / this.state.maxCounter
};
document.body.dispatchEvent(evt);
}));
if (this.state.renderCounter === 0) {
this.state.maxCounter = 0;