UNPKG

@ccos/webos-vue

Version:

A Web-Ui Framework for Skyworth/Coocaa TV

45 lines (44 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const gapValue = 48; let virtualWidth = 1920; function getVirtualWidth() { return virtualWidth; } function px2vw(width) { return 100 / virtualWidth * width; } function vw2px(vw) { return vw * virtualWidth / 100; } function getNumber(str1) { const str = str1.trim(); let i = 0; for (; i < str.length; i++) { const code = str.charCodeAt(i); if (code == 46 || code >= 48 && code <= 57) { continue; } break; } if (i == 0) { return 0; } return Number(str.substring(0, i)); } function css2px(cssStr) { const css = cssStr.toLowerCase().trim(); const numberValue = getNumber(css); if (css.endsWith("px") || css.endsWith("px;")) { return numberValue; } if (css.endsWith("vw") || css.endsWith("vw;")) { return vw2px(numberValue); } } exports.css2px = css2px; exports.gapValue = gapValue; exports.getNumber = getNumber; exports.getVirtualWidth = getVirtualWidth; exports.px2vw = px2vw; exports.vw2px = vw2px;