mixu / electroshot

Capture website screenshots with optional device and network emulation as jpg, png or pdf (with web fonts!) using Electron / Chrome.
548 stars 34 forks source link

Round getBoundingClientRect() dimensions #21

Closed shawnbot closed 7 years ago

shawnbot commented 7 years ago

Capturing elements with non-integer bounding rectangles throws a difficult-to-decipher error in electron, which I eventually traced back to the docs:

Rectangle Object

  • x Number - The x coordinate of the origin of the rectangle (must be an integer)
  • y Number - The y coordinate of the origin of the rectangle (must be an integer)
  • width Number - The width of the rectangle (must be an integer)
  • height Number - The height of the rectangle (must be an integer)

Rounding the returned bounds (with Math.floor() on the upper left coordinates and Math.ceil() on the lower right, to prevent clipping) fixes this.

mixu commented 7 years ago

awesome, thanks!

mixu commented 7 years ago

published as v1.4.0

shawnbot commented 7 years ago

No problem, cheers!