forked from dreamerslab/jquery.actual
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs.actual.min.js
6 lines (6 loc) · 1.11 KB
/
js.actual.min.js
1
2
3
4
5
6
/*! Copyright 2022
* Licensed under the MIT License (LICENSE.txt).
*
* Version: 0.1.0
*/
HTMLElement.prototype.actual=function(t,e){const o=Object.assign({},{absolute:!1,clone:!1,display:"block",convertToNumber:!1},e);let n,l,i=this;if(!0===o.clone)n=function(){i=Object.assign({},i,{style:"position: absolute !important; top: -1000 !important;"},{parentNode:document.body})},l=function(){i.parentNode.removeChild(i)};else{let t,e=[],s="";n=function(){t=Array.prototype.filter.call(i.parentElement.querySelectorAll(":scope *"),(t=>"none"===t.style.display)).concat([i]),"none"===window.getComputedStyle(i.parentElement).display&&t.push(i.parentElement),s+="visibility: hidden !important; display: "+o.display+" !important;",!0===o.absolute&&(s+="position: absolute !important;");for(let o=0;o<t.length;o++){const n=t[o],l=n.getAttribute("style");e.push(l),n.setAttribute("style",l?l+";"+s:s)}},l=function(){for(let o=0;o<t.length;o++){const n=t[o],l=e[o];void 0===l?n.removeAttribute("style"):n.setAttribute("style",l)}}}n();const s=o.convertToNumber?parseFloat(window.getComputedStyle(i)[t]):window.getComputedStyle(i)[t];return l(),s};