waitForStable
Attendre qu'un élément soit stable (ne s'anime pas) pendant le nombre de millisecondes fourni. Renvoie vrai si le sélecteur correspond à au moins un élément stable dans le DOM, sinon lance une erreur. Si le drapeau reverse est vrai, la commande renverra plutôt vrai si le sélecteur ne correspond à aucun élément stable.
Remarque : il est préférable de désactiver les animations plutôt que d'utiliser cette commande
Usage
$(selector).waitForStable({ timeout, reverse, timeoutMsg, interval })
Parameters
Name | Type | Details |
---|---|---|
options optional | WaitForOptions | options waitForStable (optionnel) |
options.timeout optional | Number | temps en ms (par défaut basé sur la valeur de configuration waitforTimeout ) |
options.reverse optional | Boolean | si vrai, il attend l'opposé (par défaut : false) |
options.timeoutMsg optional | String | s'il existe, il remplace le message d'erreur par défaut |
options.interval optional | Number | intervalle entre les vérifications (par défaut : waitforInterval ) |
Examples
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();
});
Returns
- <Boolean>
return
: vrai si l'élément est stable