@akashic-extension/akashic-timeline
Advanced tools
Comparing version 3.1.0 to 3.2.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Easing = exports.Tween = exports.Timeline = void 0; | ||
var Timeline_1 = require("./Timeline"); | ||
@@ -4,0 +5,0 @@ Object.defineProperty(exports, "Timeline", { enumerable: true, get: function () { return Timeline_1.Timeline; } }); |
@@ -14,2 +14,3 @@ import { Tween } from "./Tween"; | ||
_tweens: Tween[]; | ||
_tweensCreateQue: Tween[]; | ||
_fps: number; | ||
@@ -16,0 +17,0 @@ /** |
@@ -16,5 +16,6 @@ "use strict"; | ||
this._tweens = []; | ||
this._tweensCreateQue = []; | ||
this._fps = this._scene.game.fps; | ||
this.paused = false; | ||
scene.update.add(this._handler, this); | ||
scene.onUpdate.add(this._handler, this); | ||
} | ||
@@ -28,3 +29,3 @@ /** | ||
var t = new Tween_1.Tween(target, option); | ||
this._tweens.push(t); | ||
this._tweensCreateQue.push(t); | ||
return t; | ||
@@ -38,6 +39,7 @@ }; | ||
var index = this._tweens.indexOf(tween); | ||
if (index < 0) { | ||
var queIndex = this._tweensCreateQue.indexOf(tween); | ||
if (index < 0 && queIndex < 0) { | ||
return; | ||
} | ||
this._tweens.splice(index, 1); | ||
tween.cancel(false); | ||
}; | ||
@@ -54,3 +56,8 @@ /** | ||
} | ||
this.clear(); | ||
for (var i = 0; i < this._tweensCreateQue.length; ++i) { | ||
var tween = this._tweensCreateQue[i]; | ||
if (!tween.isFinished()) { | ||
tween.complete(); | ||
} | ||
} | ||
}; | ||
@@ -63,13 +70,14 @@ /** | ||
if (revert === void 0) { revert = false; } | ||
if (!revert) { | ||
this.clear(); | ||
return; | ||
} | ||
for (var i = 0; i < this._tweens.length; ++i) { | ||
var tween = this._tweens[i]; | ||
if (!tween.isFinished()) { | ||
tween.cancel(true); | ||
tween.cancel(revert); | ||
} | ||
} | ||
this.clear(); | ||
for (var i = 0; i < this._tweensCreateQue.length; ++i) { | ||
var tween = this._tweensCreateQue[i]; | ||
if (!tween.isFinished()) { | ||
tween.cancel(revert); | ||
} | ||
} | ||
}; | ||
@@ -80,3 +88,3 @@ /** | ||
Timeline.prototype.clear = function () { | ||
this._tweens.length = 0; | ||
this.cancelAll(false); | ||
}; | ||
@@ -87,5 +95,5 @@ /** | ||
Timeline.prototype.destroy = function () { | ||
this._tweens.length = 0; | ||
this.clear(); | ||
if (!this._scene.destroyed()) { | ||
this._scene.update.remove(this._handler, this); | ||
this._scene.onUpdate.remove(this._handler, this); | ||
} | ||
@@ -101,9 +109,11 @@ this._scene = undefined; | ||
Timeline.prototype._handler = function () { | ||
if (this._tweens.length === 0 || this.paused) { | ||
if (this.paused || this._tweens.length + this._tweensCreateQue.length === 0) { | ||
return; | ||
} | ||
this._tweens = this._tweens.concat(this._tweensCreateQue); | ||
this._tweensCreateQue = []; | ||
var tmp = []; | ||
for (var i = 0; i < this._tweens.length; ++i) { | ||
var tween = this._tweens[i]; | ||
if (!tween.isFinished()) { | ||
if (!tween.shouldRemove()) { | ||
tween._fire(1000 / this._fps); | ||
@@ -110,0 +120,0 @@ tmp.push(tween); |
@@ -17,2 +17,8 @@ import { EasingType } from "./EasingType"; | ||
_loop: boolean; | ||
/** | ||
* Tween の削除可否を表すフラグ。 | ||
* isFinished() はアクションが 0 個の場合に真を返さないが、後方互換性のためにこの挙動は変更せず、 | ||
* _stale を用いて削除判定を行う。 | ||
*/ | ||
_stale: boolean; | ||
_modifiedHandler: () => void; | ||
@@ -180,2 +186,7 @@ _destroyedHandler: () => boolean; | ||
/** | ||
* アニメーションが削除可能かどうかを返す。 | ||
* 通常、ゲーム開発者がこのメソッドを呼び出す必要はない。 | ||
*/ | ||
shouldRemove(): boolean; | ||
/** | ||
* アニメーションを実行する。 | ||
@@ -182,0 +193,0 @@ * @param delta 前フレームからの経過時間 |
@@ -20,2 +20,3 @@ "use strict"; | ||
this._loop = !!option && !!option.loop; | ||
this._stale = false; | ||
this._modifiedHandler = undefined; | ||
@@ -326,2 +327,3 @@ if (option && option.modified) { | ||
this.paused = false; | ||
this._stale = true; | ||
if (this._modifiedHandler) { | ||
@@ -346,2 +348,9 @@ this._modifiedHandler.call(this._target); | ||
/** | ||
* アニメーションが削除可能かどうかを返す。 | ||
* 通常、ゲーム開発者がこのメソッドを呼び出す必要はない。 | ||
*/ | ||
Tween.prototype.shouldRemove = function () { | ||
return this._stale || this.isFinished(); | ||
}; | ||
/** | ||
* アニメーションを実行する。 | ||
@@ -348,0 +357,0 @@ * @param delta 前フレームからの経過時間 |
{ | ||
"name": "@akashic-extension/akashic-timeline", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "timeline library for akashic", | ||
@@ -10,9 +10,7 @@ "main": "lib/index.js", | ||
"build": "tsc -p ./", | ||
"doc": "typedoc --out ./doc", | ||
"doc": "typedoc --out ./public/api src/index.ts", | ||
"lint": "npm run lint:ts && npm run lint:md", | ||
"lint:ts": "eslint src/**/*.ts spec/**/*.ts --fix", | ||
"lint:ts": "eslint \"src/**/*.ts\" --fix", | ||
"lint:md": "remark ./*.md --frail --no-stdout --quiet --rc-path ./.remarkrc", | ||
"test": "npm run test:compile && npm run test:jasmine && npm run lint", | ||
"test:compile": "cd spec/ && tsc && cd ../", | ||
"test:jasmine": "istanbul cover --report text --report html --colors -i ./lib/index.js ./node_modules/jasmine/bin/jasmine.js" | ||
"test": "jest && npm run lint" | ||
}, | ||
@@ -26,16 +24,16 @@ "author": "DWANGO Co., Ltd.", | ||
"@akashic/akashic-engine": "~3.0.0", | ||
"@akashic/eslint-config": "^0.1.2", | ||
"@types/jasmine": "^2.8.8", | ||
"@types/node": "6.0.46", | ||
"@typescript-eslint/eslint-plugin": "^4.14.1", | ||
"eslint": "^7.18.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jest": "^24.1.3", | ||
"istanbul": "^0.4.5", | ||
"jasmine": "~2.8.0", | ||
"remark-cli": "~2.0.0", | ||
"remark-lint": "~5.0.1", | ||
"@akashic/eslint-config": "^1.0.0", | ||
"@types/jest": "^27.4.0", | ||
"@types/node": "17.0.13", | ||
"@typescript-eslint/eslint-plugin": "^5.10.0", | ||
"eslint": "^8.8.0", | ||
"eslint-plugin-import": "^2.25.0", | ||
"eslint-plugin-jest": "^25.7.0", | ||
"jest": "^27.4.7", | ||
"remark-cli": "~10.0.0", | ||
"remark-lint": "~9.1.1", | ||
"rimraf": "^2.6.1", | ||
"typedoc": "^0.17.8", | ||
"typescript": "^3.8.3" | ||
"ts-jest": "^27.1.3", | ||
"typedoc": "^0.22.11", | ||
"typescript": "^4.5.5" | ||
}, | ||
@@ -42,0 +40,0 @@ "typings": "lib/index.d.ts", |
@@ -35,3 +35,3 @@ <p align="center"> | ||
使い方は [akashic-timelineの利用方法](https://github.com/akashic-games/akashic-timeline/blob/master/getstarted.md) を参照してください。 | ||
詳細なリファレンスは [APIリファレンス](https://akashic-games.github.io/reference/akashic-timeline/index.html)を参照してください。 | ||
詳細なリファレンスは [APIリファレンス](https://akashic-games.github.io/akashic-timeline/api/index.html)を参照してください。 | ||
Akashic Engineの詳細な利用方法については、 [公式ページ](https://akashic-games.github.io/) を参照してください。 | ||
@@ -57,3 +57,3 @@ | ||
`npm run build` によりgulpを使ってビルドできます。 | ||
`npm run build` でビルドできます。 | ||
@@ -67,4 +67,4 @@ ```sh | ||
1. [TSLint](https://github.com/palantir/tslint "TSLint")を使ったLint | ||
2. [Jasmine](https://jasmine.github.io "Jasmine")を使ったテスト | ||
1. [ESLint](https://eslint.org/ "ESLint")を使ったLint | ||
2. [Jest](https://jestjs.io/ja/ "Jest")を使ったテスト | ||
@@ -71,0 +71,0 @@ がそれぞれ実行されます。 |
63542
1507