| 24 | } |
| 25 | |
| 26 | override async apply(): Promise<void> { |
| 27 | const element = this.engine.element().find(`[data-video="${this.name}"]`); |
| 28 | const videoElement = element.get(0) as HTMLVideoElement | undefined; |
| 29 | |
| 30 | if (this.classes.length > 0) { |
| 31 | element.addClass('animated'); |
| 32 | for (const newClass of this.classes) { |
| 33 | if (newClass) { |
| 34 | element.addClass(newClass); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | element.data('visibility', 'invisible'); |
| 39 | element.on('animationend', (e: Event) => { |
| 40 | const target = e.target as HTMLVideoElement; |
| 41 | if (target.dataset?.visibility === 'invisible') { |
| 42 | // Cleanup video before removal |
| 43 | Video.cleanupVideoElement(target); |
| 44 | target.remove(); |
| 45 | } |
| 46 | }); |
| 47 | } else { |
| 48 | // Cleanup video before removal |
| 49 | if (videoElement) { |
| 50 | Video.cleanupVideoElement(videoElement); |
| 51 | } |
| 52 | element.remove(); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | override async didApply(): Promise<ActionApplyResult> { |
| 57 | let found = false; |