Skip to content

Commit

Permalink
WaitDOMStable is enough for scroll screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Feb 4, 2024
1 parent 2042134 commit 6300a23
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions page.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ type ScrollScreenshotOptions struct {
// FixedBottom (optional) The number of pixels to skip from the bottom.
FixedBottom float64

// WaitPerScroll wait scroll animation (default is 500ms)
// WaitPerScroll until no animation (default is 300ms)
WaitPerScroll time.Duration
}

Expand All @@ -492,7 +492,7 @@ func (p *Page) ScrollScreenshot(opt *ScrollScreenshotOptions) ([]byte, error) {
opt = &ScrollScreenshotOptions{}
}
if opt.WaitPerScroll == 0 {
opt.WaitPerScroll = time.Millisecond * 500
opt.WaitPerScroll = time.Millisecond * 300
}

metrics, err := proto.PageGetLayoutMetrics{}.Call(p)
Expand Down Expand Up @@ -566,9 +566,9 @@ func (p *Page) ScrollScreenshot(opt *ScrollScreenshotOptions) ([]byte, error) {
return nil, fmt.Errorf("scroll error: %w", err)
}

err = p.WaitStable(opt.WaitPerScroll)
err = p.WaitDOMStable(opt.WaitPerScroll, 0)
if err != nil {
return nil, fmt.Errorf("waitStable error: %w", err)
return nil, fmt.Errorf("WaitDOMStable error: %w", err)
}
}

Expand Down

0 comments on commit 6300a23

Please sign in to comment.