/*現在のフレーム数*/\r
currentFrame: 0,\r
\r
- /*開始時刻リスト (後述のupdateStateメソッドで使う)*/\r
- beginList: { \r
- next: null,\r
- value: 0\r
- },\r
- \r
- /*終了時刻リスト (後述のupdateStateメソッドで使う)*/\r
- endList: {\r
- next: null,\r
- value: Number.MAX_VALUE\r
- },\r
- \r
- /*現在の要素の状態を数値で示す(マジックナンバーは後述の大文字プロパティを使う)*/\r
- state: 0,\r
- \r
- /*アニメーション待機状態を示す定数*/\r
- WAITING: 0,\r
- \r
- /*アニメーション開始状態を示す定数*/\r
- BEGINNING: 1,\r
- \r
- /*アニメーション再生中の状態を示す定数*/\r
- PLAYING: 2,\r
- \r
- /*アニメーション終了状態を示す定数*/\r
- ENDING: 3,\r
- \r
- /*終了処理をした後の待機状態を示す定数*/\r
- POSTWAITING: 4,\r
- \r
- /*引数で指定されたフレーム数に応じて、stateプロパティを更新するメソッド*/\r
- updateState: function( /*number*/ f) {\r
- if (f === void 0) {\r
- /*引数fが指定されないときには状態を更新しない*/\r
- return this.state;\r
- }\r
- var state = this.state,\r
- wait = this.WAITING,\r
- begin = this.BEGINNING,\r
- play = this.PLAYING,\r
- end = this.ENDING,\r
- post = this.POSTWAITING,\r
- isWait = (state === wait) || (state === post);\r
- /*beginListプロパティと、endListプロパティの中で、\r
- * 現在フレーム数 f より大きい数値は、更新できる条件と無関係なので、除外しておく\r
- * また、f以下の値の中から、最大値を探して、\r
- * それがbeginプロパティの値以上であれば、\r
- * beginListとendListどちらでも、状態のstateプロパティを更新できる条件を満たす*/\r
- var list = this.beginList,\r
- startTime = -1; /*開始時刻の最大値*/\r
- while( list ) {\r
- var v = list.value;\r
- /*f以下の開始リスト値のうち、最大値をstartTimeに代入*/\r
- if ( (v <= f)\r
- && (startTime <= v) ) {\r
- startTime = v;\r
- }\r
- list = list.next;\r
- }\r
- var list = this.endList,\r
- endTime = -1; /*終了時刻の最大値*/\r
- while( list ) {\r
- var v = list.value;\r
- /*f以下の開始リスト値のうち、最大値をendTimeに代入*/\r
- if ( (v <= f)\r
- && (endTime <= v) ) {\r
- endTime = v;\r
- }\r
- list = list.next;\r
- }\r
- if ( (startTime >= this.begin) && isWait ) {\r
- return (this.state = begin);\r
- } else if (isWait) {\r
- return state;\r
- } else if (state === begin) {\r
- return (this.state = play);\r
- } else if (state === play) {\r
- return (endTime >= this.begin) ? (this.state = end) : play;\r
- } else if (state === end) {\r
- return (this.state = post);\r
- } else {\r
- return (this.state = begin);\r
- }\r
- },\r
- \r
/*アニメーションを開始させるメソッド*/\r
startAnimation: function() {\r
/*__step関数は最後に書く*/\r
list = j = void 0;\r
}\r
} ).mix( function($frame) {\r
+ $frame.up("$list").mix( {\r
+ /*開始時刻リスト (後述のupdateStateメソッドで使う)*/\r
+ beginList: { \r
+ next: null,\r
+ value: 0\r
+ },\r
+ \r
+ /*終了時刻リスト (後述のupdateStateメソッドで使う)*/\r
+ endList: {\r
+ next: null,\r
+ value: Number.MAX_VALUE\r
+ },\r
+ \r
+ /*現在の要素の状態を数値で示す(マジックナンバーは後述の大文字プロパティを使う)*/\r
+ state: 0,\r
+ \r
+ /*アニメーション待機状態を示す定数*/\r
+ WAITING: 0,\r
+ \r
+ /*アニメーション開始状態を示す定数*/\r
+ BEGINNING: 1,\r
+ \r
+ /*アニメーション再生中の状態を示す定数*/\r
+ PLAYING: 2,\r
+ \r
+ /*アニメーション終了状態を示す定数*/\r
+ ENDING: 3,\r
+ \r
+ /*終了処理をした後の待機状態を示す定数*/\r
+ POSTWAITING: 4,\r
+ \r
+ /*引数で指定されたフレーム数に応じて、stateプロパティを更新するメソッド*/\r
+ updateState: function( /*number*/ f) {\r
+ if (f === void 0) {\r
+ /*引数fが指定されないときには状態を更新しない*/\r
+ return this.state;\r
+ }\r
+ var state = this.state,\r
+ wait = this.WAITING,\r
+ begin = this.BEGINNING,\r
+ play = this.PLAYING,\r
+ end = this.ENDING,\r
+ post = this.POSTWAITING,\r
+ isWait = (state === wait) || (state === post);\r
+ /*beginListプロパティと、endListプロパティの中で、\r
+ * 現在フレーム数 f より大きい数値は、更新できる条件と無関係なので、除外しておく\r
+ * また、f以下の値の中から、最大値を探して、\r
+ * それがbeginプロパティの値以上であれば、\r
+ * beginListとendListどちらでも、状態のstateプロパティを更新できる条件を満たす*/\r
+ var list = this.beginList,\r
+ startTime = -1; /*開始時刻の最大値*/\r
+ while( list ) {\r
+ var v = list.value;\r
+ /*f以下の開始リスト値のうち、最大値をstartTimeに代入*/\r
+ if ( (v <= f)\r
+ && (startTime <= v) ) {\r
+ startTime = v;\r
+ }\r
+ list = list.next;\r
+ }\r
+ var list = this.endList,\r
+ endTime = -1; /*終了時刻の最大値*/\r
+ while( list ) {\r
+ var v = list.value;\r
+ /*f以下の開始リスト値のうち、最大値をendTimeに代入*/\r
+ if ( (v <= f)\r
+ && (endTime <= v) ) {\r
+ endTime = v;\r
+ }\r
+ list = list.next;\r
+ }\r
+ if ( (startTime >= this.begin) && isWait ) {\r
+ return (this.state = begin);\r
+ } else if (isWait) {\r
+ return state;\r
+ } else if (state === begin) {\r
+ return (this.state = play);\r
+ } else if (state === play) {\r
+ return (endTime >= this.begin) ? (this.state = end) : play;\r
+ } else if (state === end) {\r
+ return (this.state = post);\r
+ } else {\r
+ return (this.state = begin);\r
+ }\r
+ }\r
+ } );\r
+ \r
/*$endFrame オブジェクト\r
* 終了時の処理をするためのフレームを集める*/\r
$frame.up("$endFrame").mix( {\r
expect(frame.isPaused).toBeFalsy();\r
expect(frame.pauseAnimation()).toBeUndefined();\r
expect(frame.isPaused).toBeTruthy();\r
- \r
- expect(frame.WAITING).toBe(0);\r
- expect(frame.BEGINNING).toBe(1);\r
- expect(frame.PLAYING).toBe(2);\r
- expect(frame.ENDING).toBe(3);\r
- expect(frame.POSTWAITING).toBe(4);\r
- expect(frame.state).toBe(frame.WAITING);\r
- \r
- expect(frame.beginList).toEqual({\r
- next: null,\r
- value: 0\r
- });\r
- expect(frame.endList).toEqual({\r
- next: null,\r
- value: Number.MAX_VALUE\r
- });\r
+\r
});\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
it("should be this for the value (the valid partion)", function() {\r
frame.addLine(frame);\r
frame.setFrame(0);\r
});\r
- describe("the updateState method on $frame object", function() {\r
- var frame = base("$frame").up("$2");\r
- beforeEach( function() {\r
- frame.timelines = [];\r
- frame.isPaused = false;\r
- frame.state = frame.WAITING;\r
- frame.begin = 0;\r
- } );\r
- afterEach( function() {\r
- frame.timelines = [];\r
- } );\r
- /*境界条件を調べておく (limit value analysis)*/\r
- it("should be this for the value (limit value analysis)", function() {\r
- expect(typeof frame.updateState).toBe("function");\r
- expect(frame.updateState(0)).toBe(frame.BEGINNING);\r
- expect(frame.state).toBe(frame.BEGINNING);\r
- expect(frame.updateState(0)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- expect(frame.updateState(0)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- expect(frame.updateState(0)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- expect(frame.updateState(0)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- \r
- expect(frame.updateState(0)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- frame.state = 100;\r
- expect(frame.updateState(0)).toBe(frame.BEGINNING);\r
- expect(frame.state).toBe(frame.BEGINNING);\r
- expect(frame.updateState()).toBe(frame.BEGINNING);\r
- expect(frame.state).toBe(frame.BEGINNING);\r
- \r
- expect(frame.beginList).toEqual({\r
+ } );\r
+ describe("the $frame.$list object", function() {\r
+ var frame = base("$frame").$list.up("$2");\r
+ beforeEach( function() {\r
+ frame.timelines = [];\r
+ frame.isPaused = false;\r
+ frame.state = frame.WAITING;\r
+ frame.begin = 0;\r
+ } );\r
+ afterEach( function() {\r
+ frame.timelines = [];\r
+ } );\r
+ /*境界条件を調べておく (limit value analysis)*/\r
+ it("should be this for the value (limit value analysis)", function() {\r
+ \r
+ expect(frame.WAITING).toBe(0);\r
+ expect(frame.BEGINNING).toBe(1);\r
+ expect(frame.PLAYING).toBe(2);\r
+ expect(frame.ENDING).toBe(3);\r
+ expect(frame.POSTWAITING).toBe(4);\r
+ expect(frame.state).toBe(frame.WAITING);\r
+ \r
+ expect(frame.beginList).toEqual({\r
next: null,\r
value: 0\r
});\r
- expect(frame.endList).toEqual({\r
+ expect(frame.endList).toEqual({\r
next: null,\r
value: Number.MAX_VALUE\r
});\r
- \r
- } );\r
- /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
- it("should be this for the value (the valid partion)", function() {\r
- expect(frame.updateState(0)).toBe(frame.BEGINNING);\r
- expect(frame.state).toBe(frame.BEGINNING);\r
- expect(frame.updateState(1)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- expect(frame.updateState(2)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- expect(frame.updateState(3)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- expect(frame.updateState(4)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- \r
- function appendBegin(num) {\r
- frame.state = frame.WAITING;\r
- frame.begin = num;\r
- frame.beginList = {\r
- value: num,\r
- next: frame.beginList\r
- };\r
- };\r
- appendBegin(0);\r
- expect(frame.updateState(0)).toBe(frame.BEGINNING);\r
- expect(frame.state).toBe(frame.BEGINNING);\r
- expect(frame.updateState(0)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- expect(frame.updateState(0)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- \r
- appendBegin(1);\r
- expect(frame.updateState(0)).toBe(frame.WAITING);\r
- expect(frame.state).toBe(frame.WAITING);\r
- expect(frame.updateState(0)).toBe(frame.WAITING);\r
- expect(frame.state).toBe(frame.WAITING);\r
- expect(frame.updateState(1)).toBe(frame.BEGINNING);\r
- expect(frame.state).toBe(frame.BEGINNING);\r
- expect(frame.updateState(1)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- expect(frame.updateState(1)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- \r
- /*expect(frame.updateState(0)).toBe(frame.BEGINNING);\r
- expect(frame.state).toBe(frame.BEGINNING);\r
- expect(frame.updateState(0)).toBe(frame.PLAYING);\r
- expect(frame.state).toBe(frame.PLAYING);\r
- expect(frame.updateState(0)).toBe(frame.ENDING);\r
- expect(frame.state).toBe(frame.ENDING);\r
- expect(frame.updateState(0)).toBe(frame.POSTWAITING);\r
- expect(frame.state).toBe(frame.POSTWAITING);\r
- expect(frame.updateState(0)).toBe(frame.BEGINNING);\r
- expect(frame.state).toBe(frame.BEGINNING);*/\r
- } );\r
- } );\r
+ \r
+ expect(typeof frame.updateState).toBe("function");\r
+ expect(frame.updateState(0)).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState(0)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(0)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(0)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(0)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ \r
+ expect(frame.updateState(0)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ frame.state = 100;\r
+ expect(frame.updateState(0)).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState()).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ \r
+ expect(frame.beginList).toEqual({\r
+ next: null,\r
+ value: 0\r
+ });\r
+ expect(frame.endList).toEqual({\r
+ next: null,\r
+ value: Number.MAX_VALUE\r
+ });\r
+ \r
+ } );\r
+ /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
+ it("should be this for the value (the valid partion)", function() {\r
+ expect(frame.updateState(0)).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState(1)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(2)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(3)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(4)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ \r
+ function appendBegin(num) {\r
+ frame.state = frame.WAITING;\r
+ frame.begin = num;\r
+ frame.beginList = {\r
+ value: num,\r
+ next: frame.beginList\r
+ };\r
+ };\r
+ appendBegin(0);\r
+ expect(frame.updateState(0)).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState(0)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(0)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ \r
+ appendBegin(1);\r
+ expect(frame.updateState(0)).toBe(frame.WAITING);\r
+ expect(frame.state).toBe(frame.WAITING);\r
+ expect(frame.updateState(0)).toBe(frame.WAITING);\r
+ expect(frame.state).toBe(frame.WAITING);\r
+ expect(frame.updateState(1)).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState(1)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(1)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ \r
+ function appendEnd(num) {\r
+ frame.state = frame.WAITING;\r
+ frame.endList = {\r
+ value: num,\r
+ next: frame.endList\r
+ };\r
+ };\r
+ appendEnd(3);\r
+ expect(frame.updateState(1)).toBe(frame.BEGINNING);\r
+ expect(frame.state).toBe(frame.BEGINNING);\r
+ expect(frame.updateState(2)).toBe(frame.PLAYING);\r
+ expect(frame.state).toBe(frame.PLAYING);\r
+ expect(frame.updateState(3)).toBe(frame.ENDING);\r
+ expect(frame.state).toBe(frame.ENDING);\r
+ expect(frame.updateState(4)).toBe(frame.POSTWAITING);\r
+ expect(frame.state).toBe(frame.POSTWAITING);\r
+ } );\r
} );\r
- \r
describe("$begin object", function() {\r
var begin = base("$frame").$begin.up();\r
/*境界条件を調べておく (limit value analysis)*/\r