waitForStable
Espera que um elemento fique estável (sem animação) pela quantidade de milissegundos fornecida. Retorna verdadeiro se o seletor corresponder a pelo menos um elemento que está estável no DOM, caso contrário, lança um erro. Se a flag reverse for verdadeira, o comando retornará verdadeiro se o seletor não corresponder a nenhum elemento estável.
Nota: é melhor desativar as animações em vez de usar este comando
Uso
$(selector).waitForStable({ timeout, reverse, timeoutMsg, interval })
Parâmetros
Nome | Tipo | Detalhes |
---|---|---|
options opcional | WaitForOptions | opções waitForStable (opcional) |
options.timeout opcional | Number | tempo em ms (padrão baseado no valor de configuração waitforTimeout ) |
options.reverse opcional | Boolean | se verdadeiro, espera pelo oposto (padrão: false) |
options.timeoutMsg opcional | String | se existir, substitui a mensagem de erro padrão |
options.interval opcional | Number | intervalo entre verificações (padrão: waitforInterval ) |
Exemplos
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();
});
Retorna
- <Boolean>
return
: verdadeiro se o elemento estiver estável