UNPKG

acud

Version:

acg react 组件库

43 lines (42 loc) • 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPixelRatio = getPixelRatio; exports.getStyleStr = getStyleStr; exports.reRendering = void 0; exports.toLowercaseSeparator = toLowercaseSeparator; /** converting camel-cased strings to be lowercase and link it with Separato */ function toLowercaseSeparator(key) { return key.replace(/([A-Z])/g, '-$1').toLowerCase(); } /** * 获取样式字符串 * * @param style - 样式对象,React 的 CSSProperties 类型 * @returns 返回样式字符串 */ function getStyleStr(style) { return Object.keys(style).map(function (key) { return "".concat(toLowercaseSeparator(key), ": ").concat(style[key], ";"); }).join(' '); } /** Returns the ratio of the device's physical pixel resolution to the css pixel resolution */ function getPixelRatio() { return window.devicePixelRatio || 1; } /** Whether to re-render the watermark */ var reRendering = exports.reRendering = function reRendering(mutation, isWatermarkEle) { var flag = false; // Whether to delete the watermark node if (mutation.removedNodes.length) { flag = Array.from(mutation.removedNodes).some(function (node) { return isWatermarkEle(node); }); } // Whether the watermark dom property value has been modified if (mutation.type === 'attributes' && isWatermarkEle(mutation.target)) { flag = true; } return flag; };