reframe.js
Version:
Reframe.js: responsive iframes for embedded content
2 lines (1 loc) • 893 B
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).noframe=e()}(this,function(){"use strict";return function(t,e){var o="string"==typeof t?document.querySelectorAll(t):t;"length"in o||(o=[o]);for(var n=0;n<o.length;n+=1){var i=o[n],f=void 0!==e&&document.querySelector(e),c=f?document.querySelector(e):i.parentElement,a=i.offsetHeight,d=i.offsetWidth,i=i.style,c=(f?(f=window.getComputedStyle(c,null).getPropertyValue("max-width"),i.width="100%",i.maxHeight="calc(".concat(f," * ").concat(a," / ").concat(d,")")):(i.display="block",i.marginLeft="auto",i.marginRight="auto",f=d>c.offsetWidth?c.offsetWidth:d,c=d>c.offsetWidth?f*a/d:d*(a/d),i.maxHeight="".concat(c,"px"),i.width="".concat(f,"px")),100*a/d);i.height="".concat(c,"vw"),i.maxWidth="100%"}}});