waitForStable
指定されたミリ秒数、要素が安定状態(アニメーションしていない状態)になるまで待機します。セレクタがDOM内で安定した要素と少なくとも1つ一致する場合、`true` を返し、そうでない場合はエラーをスローします。`reverse`フラグが`true`の場合、セレクタが安定した要素と一致しない場合に`true`を返します。
注記: このコマンドを使用する代わりに、アニメーションを無効にすることをお勧めします。
使用方法
$(selector).waitForStable({ timeout, reverse, timeoutMsg, interval })
パラメータ
名前 | 型 | 詳細 |
---|---|---|
options オプション | WaitForOptions | waitForStable オプション(オプション) |
options.timeout オプション | 数値 | ミリ秒単位の時間(デフォルトはwaitforTimeout 設定値に基づいて設定されます) |
options.reverse オプション | ブール値 | `true`の場合、逆を待ちます(デフォルト:`false`) |
options.timeoutMsg オプション | 文字列 | 存在する場合は、デフォルトのエラーメッセージを上書きします。 |
options.interval オプション | 数値 | チェック間のインターバル(デフォルト:waitforInterval ) |
例
index.html
<head>
<style>
div {
width: 200px;
height: 200px;
background-color: red;
}
#has-animation {
animation: 3s 0s alternate slidein;
}
@keyframes slidein {
from {
margin-left: 100%;
width: 300%;
}
to {
margin-left: 0%;
width: 100%;
}
}
</style>
</head>
<body>
<div #has-animation></div>
<div #has-no-animation></div>
</body>
waitForStable.js
it('should detect that element is instable and will wait for the element to become stable', async () => {
const elem = await $('#has-animation')
await elem.waitForStable({ timeout: 3000 });
});
it('should detect that element is stable and will not wait', async () => {
const elem = await $('#has-no-animation')
await elem.waitForStable();
});