refactor: watermark代码规范

This commit is contained in:
ocean-gao 2022-05-10 15:03:52 +08:00
parent ac4ea95b7f
commit f7f040f611

View File

@ -41,7 +41,7 @@ function _close(param) {
// 监听器关闭 // 监听器关闭
_wmMo && _wmMo.disconnect(); _wmMo && _wmMo.disconnect();
_wmMo = null; _wmMo = null;
_wmTimer && clearTimeout(_wmTimer); _wmTimer && window.clearTimeout(_wmTimer);
_wmTimer = null; _wmTimer = null;
// 删除水印元素 // 删除水印元素
@ -79,6 +79,9 @@ export function createWatermark({
if (WATERMARK_DISABLED) { if (WATERMARK_DISABLED) {
return; return;
} }
if (!_wmEnable) {
return;
}
const param = { const param = {
container, container,
width, width,
@ -93,9 +96,6 @@ export function createWatermark({
zIndex, zIndex,
timestamp timestamp
}; };
if (!_wmEnable) {
return;
}
const canvas = document.createElement('canvas'); const canvas = document.createElement('canvas');
canvas.setAttribute('width', `${width}px`); canvas.setAttribute('width', `${width}px`);
canvas.setAttribute('height', `${height}px`); canvas.setAttribute('height', `${height}px`);
@ -168,7 +168,7 @@ export function createWatermark({
timeout = 1000 * 60 * 60; timeout = 1000 * 60 * 60;
} }
_wmTimer = setTimeout(() => { _wmTimer = window.setTimeout(() => {
// 触发MutationObserver // 触发MutationObserver
watermarkDiv.style.bottom = '0'; watermarkDiv.style.bottom = '0';
}, timeout); }, timeout);