mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-10-15 03:32:11 +08:00
fix: 重新渲染水印
This commit is contained in:
parent
86359cda40
commit
d072693e7d
@ -86,7 +86,8 @@ function _createWatermark(param) {
|
|||||||
parseInt(fontSize) + 5
|
parseInt(fontSize) + 5
|
||||||
);
|
);
|
||||||
|
|
||||||
const watermarkDiv = document.createElement('div');
|
let __wm = document.querySelector('.__wm');
|
||||||
|
const watermarkDiv = __wm || document.createElement('div');
|
||||||
const styleStr = `
|
const styleStr = `
|
||||||
position: ${container === document.body ? 'fixed' : 'absolute'};
|
position: ${container === document.body ? 'fixed' : 'absolute'};
|
||||||
user-select: none;
|
user-select: none;
|
||||||
@ -102,12 +103,14 @@ function _createWatermark(param) {
|
|||||||
watermarkDiv.setAttribute('style', styleStr);
|
watermarkDiv.setAttribute('style', styleStr);
|
||||||
watermarkDiv.classList.add('__wm');
|
watermarkDiv.classList.add('__wm');
|
||||||
|
|
||||||
container.insertBefore(watermarkDiv, container.firstChild);
|
if (!__wm) {
|
||||||
|
container.insertBefore(watermarkDiv, container.firstChild);
|
||||||
|
}
|
||||||
|
|
||||||
const MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
const MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
||||||
if (MutationObserver) {
|
if (MutationObserver) {
|
||||||
_wmMo = new MutationObserver(() => {
|
_wmMo = new MutationObserver(() => {
|
||||||
const __wm = document.querySelector('.__wm');
|
__wm = document.querySelector('.__wm');
|
||||||
if ((__wm && __wm.getAttribute('style') !== styleStr) || !__wm) {
|
if ((__wm && __wm.getAttribute('style') !== styleStr) || !__wm) {
|
||||||
// 避免一直触发
|
// 避免一直触发
|
||||||
_wmMo.disconnect();
|
_wmMo.disconnect();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user