From 65850f5e169d070b8d9bbe6deed13070612136c7 Mon Sep 17 00:00:00 2001 From: Rob Richardson Date: Fri, 30 Dec 2016 01:49:37 -0700 Subject: [PATCH] use the bigger of the element's size and the scroll size, captures data from overflow:auto elements --- lib/webshot.phantom.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/webshot.phantom.js b/lib/webshot.phantom.js index 7147cdb..56410e1 100644 --- a/lib/webshot.phantom.js +++ b/lib/webshot.phantom.js @@ -98,14 +98,14 @@ var _takeScreenshot = function(status) { // Handle captureSelector option page.clipRect = page.evaluate(function(selector, zoomFactor) { try { - var selectorClipRect = - document.querySelector(selector).getBoundingClientRect(); + var selectorElem = document.querySelector(selector); + var selectorClipRect = selectorElem.getBoundingClientRect(); return { top: selectorClipRect.top * zoomFactor , left: selectorClipRect.left * zoomFactor - , width: selectorClipRect.width * zoomFactor - , height: selectorClipRect.height * zoomFactor + , width: Math.max(selectorClipRect.width, selectorElem.scrollWidth) * zoomFactor + , height: Math.max(selectorClipRect.height, selectorElem.scrollHeight) * zoomFactor }; } catch (e) { throw new Error("Unable to fetch bounds for element " + selector);