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);