From: dhrname Date: Mon, 16 Feb 2015 12:25:21 +0000 (+0900) Subject: Modify a listener method for driven event X-Git-Tag: version22~305 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8591bd63d2b8cc9b118050b2d597165a67f3924f;p=sie%2Fsie.git Modify a listener method for driven event --- diff --git a/org/w3c/dom/smil.js b/org/w3c/dom/smil.js index 9aaa719..16214c1 100644 --- a/org/w3c/dom/smil.js +++ b/org/w3c/dom/smil.js @@ -143,6 +143,9 @@ base("$frame").mix ( { /*開始フレーム数。アニメーションの開始条件となる*/ begin: 0, + + /*開始時刻 (文書が読み込まれたときにDate.nowなどで取得)*/ + startTime: 0, /*活動持続時間 (Active Duration)のフレーム数。アニメーションの継続条件となる * 単位はフレーム数であって、秒数ではない*/ @@ -287,6 +290,7 @@ base("$frame").mix ( { /*イベントのリスナーとして、parseメソッドで使う*/ listener: function(evt) { evt = evt || { timeStamp: 0 }; + this.begin += Math.floor( (evt.timeStamp - this.startTime ) * this.fpms ); var s = this.$activate; s.begin = this.begin; s.timeStamp = evt.timeStamp; diff --git a/tool/Spec/spec/SvgDomSpec.js b/tool/Spec/spec/SvgDomSpec.js index b5001f8..b9b49ed 100644 --- a/tool/Spec/spec/SvgDomSpec.js +++ b/tool/Spec/spec/SvgDomSpec.js @@ -2054,6 +2054,7 @@ describe("SMIL Animation Spec", function() { it("should be this for the value (limit value analysis)", function() { expect(typeof frame.setFrame).toBe("function"); expect(frame.timelines.length).toEqual(0); + expect(frame.startTime).toEqual(0); frame.setFrame(); frame.setFrame(0); /*負の値も許される*/ @@ -2443,6 +2444,13 @@ describe("SMIL Animation Spec", function() { expect(obj.$1.activeTime).toEqual(Math.floor(1000*obj.fpms) - 1); expect(obj.$1.$activate.begin).toBe(obj.$1.begin); expect(obj.timelines[1]).toBe(obj.$1); + obj.$1.listener( { + timeStamp: 500 + } ); + expect(obj.$1.begin).toBe(Math.floor(500*obj.fpms) + 1); + expect(obj.$1.activeTime).toEqual(Math.floor(1000*obj.fpms) - Math.floor(500*obj.fpms) - 1); + expect(obj.$1.$activate.begin).toBe(obj.$1.begin); + expect(obj.timelines[1]).toBe(obj.$1); } ); /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/ it("should be this for the value (the invalid partion)", function() {