waitForStable
प्रदान की गई मिलीसेकंड समय के लिए एक एलिमेंट का स्थिर (एनिमेशन न कर रहा हो) होने का इंतजार करें। यदि सिलेक्टर कम से कम एक ऐसे एलिमेंट से मेल खाता है जो DOM में स्थिर है, तो true लौटाता है, अन्यथा एक त्रुटि फेंकता है। यदि रिवर्स फ्लैग सही है, तो कमांड तब true लौटाएगा जब सिलेक्टर किसी भी स्थिर एलिमेंट से मेल नहीं खाता है।
नोट: इस कमांड का उपयोग करने के बजाय एनिमेशन को अक्षम करना सबसे अच्छा है
उपयोग
$(selector).waitForStable({ timeout, reverse, timeoutMsg, interval })
पैरामीटर्स
नाम | प्रकार | विवरण |
---|---|---|
options वैकल्पिक | WaitForOptions | waitForStable विकल्प (वैकल्पिक) |
options.timeout वैकल्पिक | Number | समय मिलीसेकंड में (डिफॉल्ट waitforTimeout कॉन्फिग मान पर आधारित है) |
options.reverse वैकल्पिक | Boolean | यदि सही है तो यह विपरीत का इंतजार करता है (डिफॉल्ट: false) |
options.timeoutMsg वैकल्पिक | String | यदि मौजूद है तो यह डिफॉल्ट त्रुटि संदेश को ओवरराइड करता है |
options.interval वैकल्पिक | Number | जांच के बीच अंतराल (डिफॉल्ट: 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();
});
रिटर्न
- <Boolean>
return
: यदि एलिमेंट स्थिर है तो true