Fix screenshotter again
This commit is contained in:
@@ -31,14 +31,12 @@ class Screenshotter:
|
||||
page.evaluate(f"""
|
||||
let el = document.querySelector('{ticket_selector}');
|
||||
if (el) {{
|
||||
// Roztáhneme samotný kontejner se zápasy
|
||||
let wrapper = el.querySelector('.betslip-selections');
|
||||
if (wrapper) {{
|
||||
wrapper.style.setProperty('height', 'auto', 'important');
|
||||
wrapper.style.setProperty('overflow', 'visible', 'important');
|
||||
}}
|
||||
|
||||
// A teď projdeme všechny nadřazené prvky až k <body>
|
||||
while (el && el !== document.body) {{
|
||||
el.style.setProperty('height', 'auto', 'important');
|
||||
el.style.setProperty('max-height', 'none', 'important');
|
||||
@@ -62,4 +60,16 @@ class Screenshotter:
|
||||
}});
|
||||
""")
|
||||
|
||||
|
||||
|
||||
# Resize viewport if the element extends beyond the bottom edge.
|
||||
# The modal is vertically centered, so increasing the viewport by X shifts the element
|
||||
# down by X/2. To compensate: new_height = 2 * bottom - current_height.
|
||||
bbox = page.locator(ticket_selector).bounding_box()
|
||||
bottom = bbox["y"] + bbox["height"]
|
||||
vp_h = page.viewport_size["height"]
|
||||
if bottom > vp_h:
|
||||
page.set_viewport_size({"width": page.viewport_size["width"], "height": int(2 * bottom - vp_h) + 10})
|
||||
# Wait for the browser to reflow after style changes before screenshotting
|
||||
page.wait_for_timeout(500)
|
||||
page.locator(ticket_selector).screenshot(path=target_path)
|
||||
|
||||
Reference in New Issue
Block a user