()
| 72 | } |
| 73 | |
| 74 | private attach() { |
| 75 | if (this._state === 'unattached' && this._e.parentElement) { |
| 76 | ensureKeyframes(); |
| 77 | const svg = this._svg = document.createElementNS(SVG_NS, 'svg'); |
| 78 | svg.setAttribute('class', 'rough-annotation'); |
| 79 | const style = svg.style; |
| 80 | style.position = 'absolute'; |
| 81 | style.top = '0'; |
| 82 | style.left = '0'; |
| 83 | style.overflow = 'visible'; |
| 84 | style.pointerEvents = 'none'; |
| 85 | style.width = '100px'; |
| 86 | style.height = '100px'; |
| 87 | const prepend = this._config.type === 'highlight'; |
| 88 | this._e.insertAdjacentElement(prepend ? 'beforebegin' : 'afterend', svg); |
| 89 | this._state = 'not-showing'; |
| 90 | |
| 91 | // ensure e is positioned |
| 92 | if (prepend) { |
| 93 | const computedPos = window.getComputedStyle(this._e).position; |
| 94 | const unpositioned = (!computedPos) || (computedPos === 'static'); |
| 95 | if (unpositioned) { |
| 96 | this._e.style.position = 'relative'; |
| 97 | } |
| 98 | } |
| 99 | this.attachListeners(); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | private detachListeners() { |
| 104 | window.removeEventListener('resize', this._resizeListener); |
no test coverage detected