watermark-js-plus 0.11.1 → 0.11.3
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.
- package/dist/index.cjs.js +23 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.esm.js +23 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.iife.js +23 -19
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.umd.js +23 -19
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/types/docs/components/config.d.ts +0 -1
- package/dist/types/src/core/watermark.d.ts +2 -0
- package/dist/types/src/types/index.d.ts +0 -1
- package/package.json +13 -13
package/dist/index.cjs.js
CHANGED
|
@@ -193,7 +193,6 @@ var initialOptions = {
|
|
|
193
193
|
globalAlpha: 0.5,
|
|
194
194
|
mode: 'default',
|
|
195
195
|
mutationObserve: true,
|
|
196
|
-
unique: true,
|
|
197
196
|
parent: 'body',
|
|
198
197
|
onSuccess: function () { },
|
|
199
198
|
onBeforeDestroy: function () { },
|
|
@@ -866,7 +865,7 @@ var Watermark = /** @class */ (function () {
|
|
|
866
865
|
return __generator(this, function (_a) {
|
|
867
866
|
switch (_a.label) {
|
|
868
867
|
case 0:
|
|
869
|
-
if (!!
|
|
868
|
+
if (!!this.parentElement.contains(this.watermarkDom)) return [3 /*break*/, 2];
|
|
870
869
|
this.remove();
|
|
871
870
|
return [4 /*yield*/, this.create()];
|
|
872
871
|
case 1:
|
|
@@ -882,9 +881,7 @@ var Watermark = /** @class */ (function () {
|
|
|
882
881
|
(_b = (_a = this.options).onBeforeDestroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
883
882
|
(_c = this.observer) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
884
883
|
(_d = this.parentObserve) === null || _d === void 0 ? void 0 : _d.disconnect();
|
|
885
|
-
|
|
886
|
-
cancelAnimationFrame(this.checkWatermarkElementRequestID);
|
|
887
|
-
}
|
|
884
|
+
this.unbindCheckWatermarkElementEvent();
|
|
888
885
|
(_e = this.watermarkDom) === null || _e === void 0 ? void 0 : _e.remove();
|
|
889
886
|
(_g = (_f = this.options).onDestroyed) === null || _g === void 0 ? void 0 : _g.call(_f);
|
|
890
887
|
};
|
|
@@ -914,17 +911,15 @@ var Watermark = /** @class */ (function () {
|
|
|
914
911
|
};
|
|
915
912
|
Watermark.prototype.validateUnique = function () {
|
|
916
913
|
var result = true;
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
});
|
|
927
|
-
}
|
|
914
|
+
this.parentElement.childNodes.forEach(function (node) {
|
|
915
|
+
if (!result) {
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
if (Object.hasOwnProperty.call(node, '__WATERMARK__')) {
|
|
919
|
+
result = false;
|
|
920
|
+
// throw new Error('duplicate watermark error')
|
|
921
|
+
}
|
|
922
|
+
});
|
|
928
923
|
return result;
|
|
929
924
|
};
|
|
930
925
|
Watermark.prototype.validateContent = function () {
|
|
@@ -949,14 +944,14 @@ var Watermark = /** @class */ (function () {
|
|
|
949
944
|
return __generator(this, function (_a) {
|
|
950
945
|
switch (_a.label) {
|
|
951
946
|
case 0:
|
|
952
|
-
if (!!
|
|
947
|
+
if (!!this.parentElement.contains(this.watermarkDom)) return [3 /*break*/, 2];
|
|
953
948
|
this.remove();
|
|
954
949
|
return [4 /*yield*/, this.create()];
|
|
955
950
|
case 1:
|
|
956
951
|
_a.sent();
|
|
957
952
|
_a.label = 2;
|
|
958
953
|
case 2:
|
|
959
|
-
this.
|
|
954
|
+
this.bindCheckWatermarkElementEvent();
|
|
960
955
|
return [2 /*return*/];
|
|
961
956
|
}
|
|
962
957
|
});
|
|
@@ -967,7 +962,7 @@ var Watermark = /** @class */ (function () {
|
|
|
967
962
|
if (!this.watermarkDom) {
|
|
968
963
|
return;
|
|
969
964
|
}
|
|
970
|
-
this.
|
|
965
|
+
this.bindCheckWatermarkElementEvent();
|
|
971
966
|
this.observer = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
|
|
972
967
|
return __generator(this, function (_a) {
|
|
973
968
|
switch (_a.label) {
|
|
@@ -1021,6 +1016,15 @@ var Watermark = /** @class */ (function () {
|
|
|
1021
1016
|
characterData: true // 节点内容或节点文本的变动。
|
|
1022
1017
|
});
|
|
1023
1018
|
};
|
|
1019
|
+
Watermark.prototype.bindCheckWatermarkElementEvent = function () {
|
|
1020
|
+
this.unbindCheckWatermarkElementEvent();
|
|
1021
|
+
this.checkWatermarkElementRequestID = requestAnimationFrame(this.checkWatermarkElement.bind(this));
|
|
1022
|
+
};
|
|
1023
|
+
Watermark.prototype.unbindCheckWatermarkElementEvent = function () {
|
|
1024
|
+
if (!isUndefined(this.checkWatermarkElementRequestID)) {
|
|
1025
|
+
cancelAnimationFrame(this.checkWatermarkElementRequestID);
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1024
1028
|
return Watermark;
|
|
1025
1029
|
}());
|
|
1026
1030
|
|