rem-flexible
Version:
Build flexible page on mobile platform
3 lines (2 loc) • 1.12 kB
JavaScript
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).flexible=n()}(this,(function(){"use strict";return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:750,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,t=[];function o(){var e=window.devicePixelRatio||1;document.body?document.body.style.fontSize="".concat(12*e,"px"):document.addEventListener("DOMContentLoaded",o)}function i(){var t=document.documentElement,o=t.clientWidth/(e/n);t.style.fontSize="".concat(o,"px")}function d(e){e.persisted&&i()}return o(),t.push((function(){document.body.style.fontSize="",document.removeEventListener("DOMContentLoaded",o)})),i(),window.addEventListener("resize",i),window.addEventListener("pageshow",d),t.push((function(){document.documentElement.style.fontSize="",window.removeEventListener("resize",i),window.removeEventListener("pageshow",d)})),function(){return t.forEach((function(e){return e()}))}}}));
//# sourceMappingURL=flexible.umd.min.js.map