diff --git a/lib/chrome.js b/lib/chrome.js index fa67f2b..874dbb4 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -926,11 +926,16 @@ var ChromeObject = function() { this.traceMouseClick = function() { return this.evaluate('window.addEventListener("click",function(e){var t=e.clientX,n=e.clientY,l=document.createElement("div");l.style.position="absolute",l.style.width="20px",l.style.height="20px",l.style.backgroundColor="#00ff00",l.style.zIndex=99999,l.style.top=window.pageYOffset+n-10+"px",l.style.left=window.pageXOffset+t-10+"px",document.body.appendChild(l)});'); }; - + this.getWindowInnerHeight = function() { return this.getEvaluatedValue('window.innerHeight'); }; + // formula: y > 0 and y + h < ih + this.isVisibleElementInViewport = function(elementPosition) { + return (elementPosition.y > 0 && (elementPosition.y + elementPosition.h < this.getWindowInnerHeight()); + }; + this.create(); };