File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
visual-js/visual-playwright/src Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,12 @@ ${e instanceof Error ? e.message : JSON.stringify(e)}
193193 const clientDims = clipElement . getBoundingClientRect ( ) ;
194194 let { x, y, height, width } = clientDims ;
195195
196+ // Add scroll offset to coordinates in case page is scrolled prior to capture
197+ ( { x, y } = {
198+ x : x + window . scrollX ,
199+ y : y + window . scrollY ,
200+ } ) ;
201+
196202 // corrected coordinates
197203 const cX = x < 0 ? Math . abs ( x ) : 0 ;
198204 const cY = y < 0 ? Math . abs ( y ) : 0 ;
@@ -243,8 +249,8 @@ ${e instanceof Error ? e.message : JSON.stringify(e)}
243249
244250 selectorRegions . push ( {
245251 name : selector ,
246- x : Math . round ( rect . x ) ,
247- y : Math . round ( rect . y ) ,
252+ x : Math . round ( rect . x + window . scrollX ) ,
253+ y : Math . round ( rect . y + window . scrollY ) ,
248254 height : Math . round ( rect . height ) ,
249255 width : Math . round ( rect . width ) ,
250256 } ) ;
You can’t perform that action at this time.
0 commit comments