MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / waitForStableButtonRect

Function waitForStableButtonRect

content/signup-page.js:1840–1876  ·  view source on GitHub ↗
(button, timeout = 1500)

Source from the content-addressed store, hash-verified

1838}
1839
1840async function waitForStableButtonRect(button, timeout = 1500) {
1841 let previous = null;
1842 let stableSamples = 0;
1843 const start = Date.now();
1844
1845 while (Date.now() - start < timeout) {
1846 throwIfStopped();
1847 const rect = button?.getBoundingClientRect?.();
1848 if (rect && rect.width > 0 && rect.height > 0) {
1849 const snapshot = {
1850 left: rect.left,
1851 top: rect.top,
1852 width: rect.width,
1853 height: rect.height,
1854 };
1855
1856 if (
1857 previous
1858 && Math.abs(snapshot.left - previous.left) < 1
1859 && Math.abs(snapshot.top - previous.top) < 1
1860 && Math.abs(snapshot.width - previous.width) < 1
1861 && Math.abs(snapshot.height - previous.height) < 1
1862 ) {
1863 stableSamples += 1;
1864 if (stableSamples >= 2) {
1865 return;
1866 }
1867 } else {
1868 stableSamples = 0;
1869 }
1870
1871 previous = snapshot;
1872 }
1873
1874 await sleep(80);
1875 }
1876}
1877
1878function getSerializableRect(el) {
1879 const rect = el.getBoundingClientRect();

Callers 1

Calls 2

sleepFunction · 0.85
throwIfStoppedFunction · 0.70

Tested by

no test coverage detected