1+ import type { SvelteComponentDev } from 'svelte/internal'
12import { isCurrentFormat } from '../blueprintFormat'
23import CustomKeyframePanelSvelteComponent from '../components/customKeyframePanel.svelte'
34import { CUSTOM_CHANNELS } from '../mods/customKeyframesMod'
45import { events } from '../util/events'
56import { injectSvelteCompomponent } from '../util/injectSvelteComponent'
6- import { Valuable } from '../util/stores'
77import { translate } from '../util/translation'
88
9- const CURRENT_PANEL = new Valuable < HTMLDivElement | undefined > ( undefined )
9+ let currentPanel : SvelteComponentDev | undefined = undefined
1010
1111export function injectCustomKeyframePanel ( selectedKeyframe : _Keyframe ) {
1212 if (
@@ -32,23 +32,23 @@ export function injectCustomKeyframePanel(selectedKeyframe: _Keyframe) {
3232 void injectSvelteCompomponent ( {
3333 component : CustomKeyframePanelSvelteComponent ,
3434 props : {
35- currentPanel : CURRENT_PANEL as Valuable < HTMLDivElement > ,
3635 selectedKeyframe,
3736 } ,
3837 elementSelector ( ) {
3938 return element
4039 } ,
41- postMount ( ) {
40+ postMount ( comp ) {
4241 const label = jQuery ( '#panel_keyframe .panel_vue_wrapper #keyframe_type_label label' )
4342 if ( label && selectedKeyframe . channel ) {
4443 const property = selectedKeyframe . animator . channels [ selectedKeyframe . channel ]
4544 label . text ( translate ( 'panel.keyframe.keyframe_title' , `${ property . name } ` ) )
4645 }
46+ currentPanel ?. $destroy ( )
47+ currentPanel = comp
4748 } ,
4849 } )
4950}
5051
5152events . SELECT_KEYFRAME . subscribe ( kf => {
52- CURRENT_PANEL . get ( ) ?. remove ( )
53- requestAnimationFrame ( ( ) => injectCustomKeyframePanel ( kf ) )
53+ injectCustomKeyframePanel ( kf )
5454} )
0 commit comments