diff --git a/resources/js/hamsket-service-api.js b/resources/js/hamsket-service-api.js index 26532b40..f94b3724 100644 --- a/resources/js/hamsket-service-api.js +++ b/resources/js/hamsket-service-api.js @@ -44,6 +44,15 @@ window.hamsket.parseIntOrZero = function (n) { return isNaN(result) ? 0 : result; }; +window.hamsket.isInViewport = function(node) { + const rect = node.getBoundingClientRect(); + + return rect.bottom > 0 && + rect.right > 0 && + rect.left < (window.innerWidth || document.documentElement.clientWidth) && + rect.top < (window.innerHeight || document.documentElement.clientHeight); +}; + contextMenu({ window: remote.getCurrentWebContents(), showCopyImageAddress: true,