watermark-js-plus 1.5.9 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * watermark-js-plus v1.5.9
2
+ * watermark-js-plus v1.6.0
3
3
  * (c) 2022-2024 Michael Sun
4
4
  * Released under the MIT License.
5
5
  */
@@ -4215,7 +4215,7 @@ function styleInject(css, ref) {
4215
4215
  }
4216
4216
  }
4217
4217
 
4218
- var css_248z = "@keyframes watermark{0%{background-position:0 0}25%{background-position:100% 100%}50%{background-position:100% 0}75%{background-position:0 100%}to{background-position:0 0}}";
4218
+ var css_248z = "@keyframes watermark{0%{background-position:0 0}25%{background-position:100% 100%}50%{background-position:100% 0}75%{background-position:0 100%}to{background-position:0 0}}@keyframes watermark-horizontal{0%{background-position-x:0}to{background-position-x:100%}}@keyframes watermark-vertical{0%{background-position-y:0}to{background-position-y:100%}}";
4219
4219
  styleInject(css_248z);
4220
4220
 
4221
4221
  /******************************************************************************
@@ -4479,6 +4479,25 @@ var loadImage = function (url, width, height) {
4479
4479
  var generateMatrix = function (rows, columns, value) {
4480
4480
  return Array.from({ length: rows }, function () { return new Array(columns).fill(value); });
4481
4481
  };
4482
+ var generateAnimationStyle = function (movable, backgroundRepeat) {
4483
+ if (!movable) {
4484
+ return '';
4485
+ }
4486
+ var horizontalDuration = Math.random() * (8 - 2) + 2;
4487
+ var verticalDuration = Math.random() * (4 - 2) + 2;
4488
+ switch (backgroundRepeat) {
4489
+ case 'repeat':
4490
+ return 'animation: 200s linear 0s infinite alternate watermark !important;';
4491
+ case 'repeat-x':
4492
+ return "animation: ".concat(horizontalDuration, "s ease-in 0s infinite alternate watermark-vertical !important;'");
4493
+ case 'repeat-y':
4494
+ return "animation: ".concat(verticalDuration, "s ease-out 0s infinite alternate watermark-horizontal !important;'");
4495
+ case 'no-repeat':
4496
+ return "animation: ".concat(horizontalDuration, "s ease-in 0s infinite alternate watermark-horizontal, ").concat(verticalDuration, "s ease-out 0s infinite alternate watermark-vertical !important;");
4497
+ default:
4498
+ return '';
4499
+ }
4500
+ };
4482
4501
 
4483
4502
  var initialOptions = {
4484
4503
  width: 300,
@@ -5200,7 +5219,7 @@ var Watermark = /** @class */ (function () {
5200
5219
  parentElementType = this.checkParentElementType();
5201
5220
  this.watermarkDom.style.cssText = "\n z-index:".concat(this.options.zIndex, "!important;display:block!important;visibility:visible!important;transform:none!important;scale:none!important;\n ").concat(parentElementType === 'custom' ? 'top:0!important;bottom:0!important;left:0!important;right:0!important;height:100%!important;pointer-events:none!important;position:absolute!important;' : 'position:relative!important;', "\n ");
5202
5221
  backgroundSize = generateBackgroundSize(this.options);
5203
- watermarkInnerDom.style.cssText = "\n display:block!important;visibility:visible!important;pointer-events:none;top:0;bottom:0;left:0;right:0;transform:none!important;scale:none!important;\n position:".concat(parentElementType === 'root' ? 'fixed' : 'absolute', "!important;-webkit-print-color-adjust:exact!important;width:100%!important;height:100%!important;\n z-index:").concat(this.options.zIndex, "!important;background-image:url(").concat(image, ")!important;background-repeat:").concat(this.options.backgroundRepeat, "!important;\n background-size:").concat(backgroundSize[0], "px ").concat(backgroundSize[1], "px!important;background-position:").concat(this.options.backgroundPosition, ";\n ").concat(this.options.movable ? 'animation: 200s linear 0s infinite alternate watermark !important;' : '', "\n ");
5222
+ watermarkInnerDom.style.cssText = "\n display:block!important;visibility:visible!important;pointer-events:none;top:0;bottom:0;left:0;right:0;transform:none!important;scale:none!important;\n position:".concat(parentElementType === 'root' ? 'fixed' : 'absolute', "!important;-webkit-print-color-adjust:exact!important;width:100%!important;height:100%!important;\n z-index:").concat(this.options.zIndex, "!important;background-image:url(").concat(image, ")!important;background-repeat:").concat(this.options.backgroundRepeat, "!important;\n background-size:").concat(backgroundSize[0], "px ").concat(backgroundSize[1], "px!important;background-position:").concat(this.options.backgroundPosition, ";\n ").concat(generateAnimationStyle(this.options.movable, this.options.backgroundRepeat), "\n ");
5204
5223
  this.watermarkDom.appendChild(watermarkInnerDom);
5205
5224
  this.parentElement.appendChild(this.watermarkDom);
5206
5225
  if (this.options.mutationObserve) {