return b;\r
}\r
/*限界の収束回数は100回*/\r
- for (var i=0;i<100;++i) {\r
+ for (var i=0;i<100;i=(i+1)|0) {\r
/*数値nは与えられた三次方程式を微分したもの*/\r
var n = 3* a0 *b*b + 2 * a1 *b + a2;\r
if (!n || ( (fb < eps) && (fb > -eps) )) {\r
/*開始を設定されたタイムライン ($beginオブジェクト)*/\r
timeline: base("$frame").$begin,\r
\r
- /*アニメが終了した際の後処理\r
- * 終了処理をしたいときは、falseを値として返す*/\r
- _setEndFrame: function(frame) {\r
+ /*_setEndFrameメソッドで終了処理をさせたいときに、呼び出されるメソッド\r
+ * 終了処理が必要なときだけ、trueを返す*/\r
+ checkEnd: function (frame) {\r
+ var line = this.timeline,\r
+ end = line.begin + line.activeTime;\r
+ if (!line.isResolved || isNaN(end)) {\r
+ /*未解決など問題が発生したとき*/\r
+ line = frame = void 0;\r
+ return false;\r
+ } else if (\r
+ ( ( frame < line.begin )\r
+ || ( end <= frame )\r
+ ) && (this.state === "playing") ) {\r
+ /*stateプロパティを書き換えることで、一度のみ、終了処理させる*/\r
+ this.state = "idling";\r
+ line = frame = void 0;\r
+ return true;\r
+ } else {\r
+ line = frame = void 0;\r
+ return false;\r
+ }\r
+ },\r
+ \r
+ /*アニメが終了した際の後処理*/\r
+ _setEndFrame: function (frame) {\r
var line = this.timeline,\r
end = line.begin + line.activeTime;\r
if (!line.isResolved || isNaN(end)) {\r
/*後の_setFrameメソッドで使うダミー*/\r
__setAttribute: function(){},\r
\r
- _setFrame: function(currentTime) {\r
+ _setFrame: function(currentFrame) {\r
/*__transformListの中で、自分より後の項目に再生中のものがあれば、\r
*アニメーションを再生させないで、後に続く項目に任せる*/\r
var list = this.element.__transformList,\r
this.setAttribute = isActive ? this.__setAttribute\r
: this.$animateElement.setAttribute;\r
/*上書きされたメソッドを呼び出す*/\r
- this.$animateElement._setFrame.call(this, currentTime);\r
+ this.$animateElement._setFrame.call(this, currentFrame);\r
+ },\r
+ \r
+ _setEndFrame: function(currentFrame) {\r
+ this.$animateElement._setEndFrame.call(this, currentFrame);\r
},\r
\r
/*setAddメソッドのオーバライド\r
expect($set.element).toBeNull();\r
} );\r
} );\r
+ describe("An checkEnd method", function() {\r
+ var $set, ele, frame;\r
+ beforeEach( function() {\r
+ $set = base("$calcMode").$attribute.$setElement.up();\r
+ var p = document.createElementNS("http://www.w3.org/2000/svg", "g");\r
+ ele = document.createElementNS("http://www.w3.org/2000/svg", "set");\r
+ p.appendChild(ele);\r
+ frame = base("$frame");\r
+ } );\r
+ /*境界条件を調べておく (limit value analysis)*/\r
+ it("should be this for the value (limit value analysis)", function() {\r
+ expect($set.checkEnd()).toBeFalsy();\r
+ $set.init(ele);\r
+ frame.setFrame(0);\r
+ frame.$endFrame.setFrame(0);\r
+ expect($set.checkEnd()).toBeFalsy();\r
+ } );\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value (the valid partion)", function() {\r
+ ele.setAttributeNS(null, "dur", "1s");\r
+ ele.setAttributeNS(null, "attributeName", "fill");\r
+ ele.setAttributeNS(null, "to", "red");\r
+ $set.init(ele);\r
+ expect($set.checkEnd(0)).toBeFalsy();\r
+ expect($set.checkEnd(24)).toBeFalsy();\r
+ $set.state = "playing";\r
+ expect($set.checkEnd(25)).toBeTruthy();\r
+ expect($set.state).toBe("idling");\r
+ expect($set.checkEnd(26)).toBeFalsy();\r
+ } );\r
+ /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
+ it("should be this for the value (the invalid partion)", function() {\r
+ $set.timeline.isResolved = false;\r
+ expect($set.checkEnd(0)).toBeFalsy();\r
+ $set.timeline.activeTime = null;\r
+ expect($set.checkEnd(0)).toBeFalsy();\r
+ $set.timeline = null;\r
+ expect(function() {\r
+ $set.checkEnd(0);\r
+ } ).toThrow();\r
+ } );\r
+ } );\r
+ \r
describe("An init method", function() {\r
var $set, ele, frame;\r
beforeEach( function() {\r
expect($set.timeline).toBe(frame.$begin);\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
- it("should be this for the value (the valid partion on a spline mode )", function() {\r
+ it("should be this for the value (the valid partion )", function() {\r
ele.setAttributeNS(null, "to", "t1");\r
$set.init(ele);\r
expect($set.to).toBe("t1");\r