You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add RENDER_COMPLETE signal for precise screenshot timing
- Updated README with new feature for controlling screenshot timing
- Added documentation for `render_timeout` parameter
- Explained use cases for custom rendering signal
- Provided example of how to use RENDER_COMPLETE in HTML/JavaScript
- Updated CLI options to include render timeout parameter
For pages with dynamic content or JavaScript animations, you can control exactly when the screenshot is taken using the `RENDER_COMPLETE` signal:
273
+
274
+
```python
275
+
from snap_html import generate_image_sync
276
+
277
+
# Specify a longer timeout for waiting for the RENDER_COMPLETE signal
278
+
screenshot = generate_image_sync(
279
+
"https://www.example.com",
280
+
render_timeout=15.0# Wait up to 15 seconds for RENDER_COMPLETE signal
281
+
)
282
+
```
283
+
284
+
In your HTML/JavaScript, add a console log message to signal when rendering is complete:
285
+
286
+
```html
287
+
<script>
288
+
// After your page is fully rendered and ready for screenshot
289
+
window.addEventListener('load', function() {
290
+
// Do any final rendering tasks
291
+
setTimeout(function() {
292
+
console.log('RENDER_COMPLETE');
293
+
}, 500); // Add a small delay if needed
294
+
});
295
+
</script>
296
+
```
297
+
298
+
This is particularly useful for:
299
+
- Pages with dynamic content loading
300
+
- JavaScript animations or transitions
301
+
- Asynchronous data fetching
302
+
- Custom rendering logic
303
+
304
+
If the `RENDER_COMPLETE` signal is not received within the specified timeout, snap-html will fall back to using the "networkidle" state to determine when to take the screenshot.
0 commit comments