Cleanup and typos.

This commit is contained in:
Arnavion
2014-08-08 22:51:12 -07:00
parent 03ed6091c2
commit 2eaa6e451d
2 changed files with 19 additions and 18 deletions
+18 -17
View File
@@ -102,7 +102,7 @@ module libjass.renderers {
toggle(): void;
/**
* Enable or disable the renderer.
* Enable or disable the clock.
*
* @param {boolean} enabled If true, the clock is enabled, otherwise it's disabled.
* @return {boolean} True if the clock is now in the given state, false if it was already in that state.
@@ -261,9 +261,7 @@ module libjass.renderers {
this._enabled = true;
if (this._nextAnimationFrameRequestId === null) {
this._nextAnimationFrameRequestId = requestAnimationFrame(() => this._onTimerTick());
}
this._startTicking();
return true;
}
@@ -287,10 +285,7 @@ module libjass.renderers {
this._dispatchEvent(ClockEvent.Stop, []);
if (this._nextAnimationFrameRequestId !== null) {
cancelAnimationFrame(this._nextAnimationFrameRequestId);
this._nextAnimationFrameRequestId = null;
}
this._stopTicking();
return true;
}
@@ -331,9 +326,7 @@ module libjass.renderers {
return;
}
if (this._nextAnimationFrameRequestId === null) {
this._nextAnimationFrameRequestId = requestAnimationFrame(() => this._onTimerTick());
}
this._startTicking();
}
private _onVideoPause(): void {
@@ -357,12 +350,7 @@ module libjass.renderers {
return;
}
cancelAnimationFrame(this._nextAnimationFrameRequestId);
this._nextAnimationFrameRequestId = null;
if (libjass.verboseMode) {
console.log("VideoClock._onVideoPause: Cancelled VideoClock._nextAnimationFrameRequestId");
}
this._stopTicking();
}
private _onVideoSeeking(): void {
@@ -411,6 +399,19 @@ module libjass.renderers {
this._nextAnimationFrameRequestId = requestAnimationFrame(() => this._onTimerTick());
}
private _startTicking(): void {
if (this._nextAnimationFrameRequestId === null) {
this._nextAnimationFrameRequestId = requestAnimationFrame(() => this._onTimerTick());
}
}
private _stopTicking(): void {
if (this._nextAnimationFrameRequestId !== null) {
cancelAnimationFrame(this._nextAnimationFrameRequestId);
this._nextAnimationFrameRequestId = null;
}
}
// EventSource members
_eventListeners: Map<ClockEvent, Function[]> = new Map<ClockEvent, Function[]>();
addEventListener: (type: ClockEvent, listener: Function) => void;
+1 -1
View File
@@ -145,7 +145,7 @@ module libjass.renderers {
* Runs when the clock's current time changed. This might be a result of either regular playback or seeking.
*/
_onClockTick(): void {
var currentTime = this.clock.currentTime;
var currentTime = this._clock.currentTime;
if (libjass.verboseMode) {
console.log("NullRenderer._onClockTick: currentTime = " + currentTime);