From 75a0a7c69719ddad364c39242c73a07307aad9fa Mon Sep 17 00:00:00 2001 From: ragingwind Date: Sun, 3 Feb 2013 11:35:19 +0900 Subject: [PATCH 1/2] Support chrome browser on google tv add setter to avoid exception [1] and using defineProperty instead of __defineGetter__ to inheritance error [2] [1]: TypeError: Cannot set property interationTIme of par 0-NaN(0@0) [par 1-undefined (0 @-0.994)[] ] which has only a getter [2]: can't found super object (ParGroup) if it's using __defineGetter__ --- web-animation.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/web-animation.js b/web-animation.js index e9e23723..2a6980e9 100644 --- a/web-animation.js +++ b/web-animation.js @@ -147,7 +147,7 @@ var TimedItem = function(timing, startTime, parentGroup) { }.bind(this)); this._startTime = startTime; this.currentIteration = null; - this.iterationTime = null; + this._iterationTime = null; this.animationTime = null; this._reversing = false; @@ -180,6 +180,14 @@ var TimedItem = function(timing, startTime, parentGroup) { this._pauseStartTime = 0; }; +TimedItem.prototype.__defineGetter__('iterationTime', function() { + return this._iterationTime; +}); + +TimedItem.prototype.__defineSetter__('iterationTime', function(time) { + this._iterationTime = time; +}); + TimedItem.prototype.__defineGetter__('timeDrift', function() { if (this.locallyPaused) { return this._effectiveParentTime - this.startTime - @@ -2074,12 +2082,17 @@ var timeZero = useHighResTime ? 0 : Date.now(); // Massive hack to allow things to be added to the parent group and start // playing. Maybe this is right though? -DEFAULT_GROUP.__defineGetter__('iterationTime', function() { - if (!isDefinedAndNotNull(timeNow)) { - timeNow = useHighResTime ? performance.now() : Date.now() - timeZero; - setTimeout(function() { timeNow = undefined; }, 0); +Object.defineProperty(DEFAULT_GROUP, 'iterationTime', { + get: function() { + if (!isDefinedAndNotNull(timeNow)) { + timeNow = useHighResTime ? performance.now() : Date.now() - timeZero; + setTimeout(function() { timeNow = undefined; }, 0); + } + return timeNow / 1000; + }, + set: function(time) { + this._iterationTime = time; } - return timeNow / 1000; }); var ticker = function(frameTime) { From ff82eecd452151baf8d9098718a3833a896ebac1 Mon Sep 17 00:00:00 2001 From: ragingwind Date: Wed, 6 Feb 2013 21:05:54 +0900 Subject: [PATCH 2/2] remove unless code about iterationTime --- web-animation.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/web-animation.js b/web-animation.js index 2a6980e9..fb375511 100644 --- a/web-animation.js +++ b/web-animation.js @@ -147,7 +147,7 @@ var TimedItem = function(timing, startTime, parentGroup) { }.bind(this)); this._startTime = startTime; this.currentIteration = null; - this._iterationTime = null; + this.iterationTime = null; this.animationTime = null; this._reversing = false; @@ -180,14 +180,6 @@ var TimedItem = function(timing, startTime, parentGroup) { this._pauseStartTime = 0; }; -TimedItem.prototype.__defineGetter__('iterationTime', function() { - return this._iterationTime; -}); - -TimedItem.prototype.__defineSetter__('iterationTime', function(time) { - this._iterationTime = time; -}); - TimedItem.prototype.__defineGetter__('timeDrift', function() { if (this.locallyPaused) { return this._effectiveParentTime - this.startTime - @@ -2089,9 +2081,6 @@ Object.defineProperty(DEFAULT_GROUP, 'iterationTime', { setTimeout(function() { timeNow = undefined; }, 0); } return timeNow / 1000; - }, - set: function(time) { - this._iterationTime = time; } });