File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
templates/typescript/computer-use/tools Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -190,11 +190,19 @@ export class ComputerTool implements BaseAnthropicTool {
190190 await this . page . waitForTimeout ( 100 ) ;
191191 }
192192
193- const amount = scrollAmountValue || 100 ;
193+ const pageDimensions = await this . page . evaluate ( ( ) => {
194+ return { h : window . innerHeight , w : window . innerWidth } ;
195+ } ) ;
196+ const pagePartitions = 25 ;
197+ const scrollFactor = ( scrollAmountValue || 10 ) / pagePartitions ;
194198
195199 if ( scrollDirection === 'down' || scrollDirection === 'up' ) {
200+ const amount = pageDimensions . h * scrollFactor ;
201+ console . log ( `Scrolling ${ amount / pageDimensions . h * 100 } % ${ scrollDirection } ` ) ;
196202 await this . page . mouse . wheel ( 0 , scrollDirection === 'down' ? amount : - amount ) ;
197203 } else {
204+ const amount = pageDimensions . w * scrollFactor ;
205+ console . log ( `Scrolling ${ amount / pageDimensions . w * 100 } % ${ scrollDirection } ` ) ;
198206 await this . page . mouse . wheel ( scrollDirection === 'right' ? amount : - amount , 0 ) ;
199207 }
200208
You can’t perform that action at this time.
0 commit comments