1
+ import type { SvelteComponentDev } from 'svelte/internal'
1
2
import { isCurrentFormat } from '../blueprintFormat'
2
3
import CustomKeyframePanelSvelteComponent from '../components/customKeyframePanel.svelte'
3
4
import { CUSTOM_CHANNELS } from '../mods/customKeyframesMod'
4
5
import { events } from '../util/events'
5
6
import { injectSvelteCompomponent } from '../util/injectSvelteComponent'
6
- import { Valuable } from '../util/stores'
7
7
import { translate } from '../util/translation'
8
8
9
- const CURRENT_PANEL = new Valuable < HTMLDivElement | undefined > ( undefined )
9
+ let currentPanel : SvelteComponentDev | undefined = undefined
10
10
11
11
export function injectCustomKeyframePanel ( selectedKeyframe : _Keyframe ) {
12
12
if (
@@ -32,23 +32,23 @@ export function injectCustomKeyframePanel(selectedKeyframe: _Keyframe) {
32
32
void injectSvelteCompomponent ( {
33
33
component : CustomKeyframePanelSvelteComponent ,
34
34
props : {
35
- currentPanel : CURRENT_PANEL as Valuable < HTMLDivElement > ,
36
35
selectedKeyframe,
37
36
} ,
38
37
elementSelector ( ) {
39
38
return element
40
39
} ,
41
- postMount ( ) {
40
+ postMount ( comp ) {
42
41
const label = jQuery ( '#panel_keyframe .panel_vue_wrapper #keyframe_type_label label' )
43
42
if ( label && selectedKeyframe . channel ) {
44
43
const property = selectedKeyframe . animator . channels [ selectedKeyframe . channel ]
45
44
label . text ( translate ( 'panel.keyframe.keyframe_title' , `${ property . name } ` ) )
46
45
}
46
+ currentPanel ?. $destroy ( )
47
+ currentPanel = comp
47
48
} ,
48
49
} )
49
50
}
50
51
51
52
events . SELECT_KEYFRAME . subscribe ( kf => {
52
- CURRENT_PANEL . get ( ) ?. remove ( )
53
- requestAnimationFrame ( ( ) => injectCustomKeyframePanel ( kf ) )
53
+ injectCustomKeyframePanel ( kf )
54
54
} )
0 commit comments