diff options
| author | Eltrac <hi@guhub.cn> | 2025-09-15 10:10:29 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-09-15 10:10:29 +0800 |
| commit | 4cb9d21fb8860d3401db5d94d30c309385599a2e (patch) | |
| tree | 08bd2cb39bc2602fec302c78f3990edfd11a93b1 /src/overlay.js | |
initial commit
Diffstat (limited to 'src/overlay.js')
| -rw-r--r-- | src/overlay.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/overlay.js b/src/overlay.js new file mode 100644 index 0000000..c5dd853 --- /dev/null +++ b/src/overlay.js @@ -0,0 +1,35 @@ +export default class Overlay { + zIndex = 900; + zIndexHidden = -100; + + constructor() { + const overlay = document.createElement('div'); + overlay.id = 'libo-overlay'; + overlay.classList.add('libo-overlay'); + + // initialized state + overlay.style.zIndex = this.zIndexHidden; + overlay.style.opacity = '0'; + + this.element = overlay; + document.body.appendChild(overlay); + + return this; + } + + add(element) { + this.element.innerHTML = ''; + this.element.appendChild(element.element || element); + return this; + } + + show() { + this.element.style.opacity = '1'; + this.element.style.zIndex = this.zIndex; + } + + hide() { + this.element.style.opacity = '0'; + this.element.style.zIndex = '-100'; + } +} |
