Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function (designWidth = 20 / 375) {
- const docEle: HTMLElement = document.documentElement;
- const resizeEvt: string = "orientationchange" in window ? "orientationchange" : "resize";
- const recalc: EventListener = () => {
- const fontSize = Math.floor(docEle.clientWidth * designWidth);
- docEle.style.fontSize = fontSize + "px";
- const localFontSize = parseInt(window.getComputedStyle(docEle).getPropertyValue('font-size'));
- docEle.style.fontSize = fontSize * (fontSize / localFontSize) + "px";
- };
- on('DOMContentLoaded', recalc, document);
- on(resizeEvt, recalc);
- on('unload', () => { off('DOMContentLoaded', recalc); off(resizeEvt, recalc); })
- })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement