refactor interactions_service to use object destructuring for scroll coordinates, enhancing code clarity and maintainability
Build and Push Docker Images / build-and-push (push) Successful in 21s
Build and Push Docker Images / build-and-push (push) Successful in 21s
This commit is contained in:
@@ -225,19 +225,17 @@ async def interactions_service(
|
||||
target_scroll_y = max(0.0, y - (inner_h / 2.0))
|
||||
|
||||
await page.evaluate(
|
||||
"""(sx, sy) => {
|
||||
"""({ sx, sy }) => {
|
||||
window.scrollTo({ left: sx, top: sy, behavior: 'auto' });
|
||||
}""",
|
||||
target_scroll_x,
|
||||
target_scroll_y,
|
||||
{"sx": target_scroll_x, "sy": target_scroll_y},
|
||||
)
|
||||
|
||||
# Wait for scroll offsets to settle before resolving the viewport point.
|
||||
try:
|
||||
await page.wait_for_function(
|
||||
"""(sx, sy) => Math.abs(window.scrollX - sx) <= 2 && Math.abs(window.scrollY - sy) <= 2""",
|
||||
target_scroll_x,
|
||||
target_scroll_y,
|
||||
"""({ sx, sy }) => Math.abs(window.scrollX - sx) <= 2 && Math.abs(window.scrollY - sy) <= 2""",
|
||||
{"sx": target_scroll_x, "sy": target_scroll_y},
|
||||
timeout=10000,
|
||||
)
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user