From 0b642e7e963c002fe486d44a7444d015037cba55 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 1 Dec 2016 08:59:18 -0600 Subject: [PATCH] chore(DomController): updates --- src/util/dom-controller.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/util/dom-controller.ts b/src/util/dom-controller.ts index fb06acae02..7fad2ada51 100644 --- a/src/util/dom-controller.ts +++ b/src/util/dom-controller.ts @@ -12,14 +12,14 @@ export class DomController { private w: Function[] = []; private q: boolean; - read(fn: Function, ctx?: any): Function { + read(fn: {(timeStamp: number)}, ctx?: any): Function { const task = !ctx ? fn : fn.bind(ctx); this.r.push(task); this.queue(); return task; } - write(fn: Function, ctx?: any): Function { + write(fn: {(timeStamp: number)}, ctx?: any): Function { const task = !ctx ? fn : fn.bind(ctx); this.w.push(task); this.queue(); @@ -30,28 +30,29 @@ export class DomController { return removeArrayItem(this.r, task) || removeArrayItem(this.w, task); } - private queue() { - if (!this.q) { - this.q = true; - nativeRaf(timestamp => { - this.flush(timestamp); + protected queue() { + const self = this; + if (!self.q) { + self.q = true; + nativeRaf(function rafCallback(timeStamp) { + self.flush(timeStamp); }); } } - private flush(timestamp: number) { + protected flush(timeStamp: number) { let err; let task; try { // ******** DOM READS **************** while (task = this.r.shift()) { - task(timestamp); + task(timeStamp); } // ******** DOM WRITES **************** while (task = this.w.shift()) { - task(timestamp); + task(timeStamp); } } catch (e) { err = e;