| 37 | ); |
| 38 | |
| 39 | export class LoadingOverlay implements Mountable { |
| 40 | readonly root: HTMLElement; |
| 41 | private unsubRenderStarted: () => void; |
| 42 | private unsubRenderFinished: () => void; |
| 43 | private dragCount = 0; |
| 44 | |
| 45 | constructor(api: alphaTab.AlphaTabApi) { |
| 46 | this.root = parseHtml(html` |
| 47 | <div class="at-overlay"> |
| 48 | <div class="at-overlay-content"> |
| 49 | <div class="cmp-spinner"></div> |
| 50 | </div> |
| 51 | </div> |
| 52 | `); |
| 53 | mount(this.root, '.cmp-spinner', new Spinner()); |
| 54 | |
| 55 | this.unsubRenderStarted = api.renderStarted.on(isResize => { |
| 56 | if (!isResize) { |
| 57 | this.setVisible(true); |
| 58 | } |
| 59 | }); |
| 60 | this.unsubRenderFinished = api.renderFinished.on(() => { |
| 61 | this.setVisible(false); |
| 62 | }); |
| 63 | } |
| 64 | |
| 65 | setVisible(visible: boolean): void { |
| 66 | this.root.classList.toggle('visible', visible); |
| 67 | } |
| 68 | |
| 69 | enterDrag(): void { |
| 70 | this.dragCount++; |
| 71 | this.setVisible(true); |
| 72 | } |
| 73 | |
| 74 | leaveDrag(): void { |
| 75 | this.dragCount = Math.max(0, this.dragCount - 1); |
| 76 | if (this.dragCount === 0) { |
| 77 | this.setVisible(false); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | dispose(): void { |
| 82 | this.unsubRenderStarted(); |
| 83 | this.unsubRenderFinished(); |
| 84 | this.root.remove(); |
| 85 | } |
| 86 | } |
nothing calls this directly
no outgoing calls
no test coverage detected