utils.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  2. //#region ../../packages/components/watermark/src/utils.ts
  3. /** converting camel-cased strings to be lowercase and link it with Separator */
  4. function toLowercaseSeparator(key) {
  5. return key.replace(/([A-Z])/g, "-$1").toLowerCase();
  6. }
  7. function getStyleStr(style) {
  8. return Object.keys(style).map((key) => `${toLowercaseSeparator(key)}: ${style[key]};`).join(" ");
  9. }
  10. /** Returns the ratio of the device's physical pixel resolution to the css pixel resolution */
  11. function getPixelRatio() {
  12. return window.devicePixelRatio || 1;
  13. }
  14. /** Whether to re-render the watermark */
  15. const reRendering = (mutation, watermarkElement) => {
  16. let flag = false;
  17. if (mutation.removedNodes.length && watermarkElement) flag = Array.from(mutation.removedNodes).includes(watermarkElement);
  18. if (mutation.type === "attributes" && mutation.target === watermarkElement) flag = true;
  19. return flag;
  20. };
  21. //#endregion
  22. exports.getPixelRatio = getPixelRatio;
  23. exports.getStyleStr = getStyleStr;
  24. exports.reRendering = reRendering;
  25. exports.toLowercaseSeparator = toLowercaseSeparator;
  26. //# sourceMappingURL=utils.js.map