DOM

AnimationEffect.getComputedTiming() メソッド

 編集:2022.10.24 by T.A.

[Edge]。→

AnimationEffect の計算されたタイミング プロパティを返します。

返されるオブジェクトの属性の多くは、AnimationEffect.getTiming() メソッドによって返されるオブジェクトと共通ですが、このオブジェクトによって返される値は、次の点で異なります:

duration
反復期間の計算値を返します。duration が文字列 auto の場合、この属性は 0 を返します。
fill
auto 値は、適切な fill 値に置き換えられます。
構文
AnimationEffect.getComputedTiming()
AnimationEffect AnimationEffect
戻り値

次のプロパティを含むオブジェクト:

endTime
アニメーションの開始からのミリ秒単位のアニメーションの終了時間(KeyframeEffectAnimation に関連付けられている場合)。(その計算には endDelay も含まれます。)
activeDuration
アニメーションの効果が実行されるミリ秒単位の時間。これは、反復期間に反復回数を掛けた値に等しくなります。
localTime
ミリ秒単位のアニメーションの現在の時間。KeyframeEffectAnimation に関連付けられていない場合 null です。
progress
アニメーションが現在の反復をどのくらい進んでいるかを 0 から 1 の値で示します。アニメーションが実行されていないか、その KeyframeEffectAnimation に関連付けられていない場合は null を返します。
currentIteration
このアニメーションがループした回数で、0 から始まります。アニメーションが実行されていない場合、またはその KeyframeEffectAnimation に関連付けられていない場合は null を返します。

HTML:

<DIV id=IdTest style="width:1em">■</DIV>
<BUTTON id=IdPlay>再生</BUTTON>
<BUTTON id=IdStop>終了</BUTTON>
<BUTTON id=IdCancel>中止</BUTTON>
<BR>
<SPAN id=IdLog></SPAN>

JavaScript:

KE=new KeyframeEffect(  //アニメーション データの作成:
  IdTest, [  //ターゲット。
    {transform:'translateX(0)'}
    , {transform:'translateX(500px)'}  //X軸移動。
  ]
  , {duration:10000, fill:'auto'}  //掛ける時間、?。
);
Ani=new Animation(KE, document.timeline);  //アニメーション作成。

function JobPlay(){  //「再生」ボタンが押された時の処理:
  Ani.play();        //アニメーション再生。
}
function JobStop(){ //「終了」ボタンが押された時の処理:
  Ani.finish();       //アニメーション終了。
}
function JobCancel(){ //「中止」ボタンが押された時の処理:
  Ani.cancel();       //アニメーション中止。
}
IdPlay.onclick=JobPlay;   //ボタンにイベント割り当て。
IdStop.onclick=JobStop;   //ボタンにイベント割り当て。
IdCancel.onclick=JobCancel; //ボタンにイベント割り当て。

D=Ani.effect;  //=[object]:[object KeyframeEffect]
	//target=[object]:[object HTMLDivElement]
	//pseudoElement=[object]:null
	//composite=[string]:replace
	//getKeyframes=[function]:function getKeyframes() { [native code] }
	//setKeyframes=[function]:function setKeyframes() { [native code] }
	//getComputedTiming=[function]:function getComputedTiming() { [native code] }
	//getTiming=[function]:function getTiming() { [native code] }
	//updateTiming=[function]:function updateTiming() { [native code] }
D=Ani.effect.getTiming();  //=[object]:[object Object]
	//delay=[number]:0
	//direction=[string]:normal
	//duration=[number]:10000
	//easing=[string]:linear
	//endDelay=[number]:0
	//fill=[string]:auto
	//iterationStart=[number]:0
	//iterations=[number]:1
D2=Ani.effect.getComputedTiming();  //=[object]:[object Object]
	//delay=[number]:0
	//direction=[string]:normal
	//duration=[number]:10000
	//easing=[string]:linear
	//endDelay=[number]:0
	//fill=[string]:none
	//iterationStart=[number]:0
	//iterations=[number]:1
	//activeDuration=[number]:10000
	//currentIteration=[object]:null
	//endTime=[number]:10000
	//localTime=[object]:null
	//progress=[object]:null

new KeyframeEffect()new Animation()effectgetTiming()


テスト