1+ import { DOCUMENT } from '@angular/common' ;
12import {
23 afterNextRender ,
34 DestroyRef ,
@@ -9,6 +10,7 @@ import {
910 isSignal ,
1011 signal ,
1112} from '@angular/core' ;
13+ import { ClassName } from '@tweakpane/core' ;
1214import { Pane } from 'tweakpane' ;
1315import { PaneConfig } from 'tweakpane/dist/types/pane/pane-config' ;
1416import { NgtTweakFolder } from './folder' ;
@@ -26,9 +28,11 @@ export class NgtTweakPane {
2628 width = input < string | number > ( '256px' ) ;
2729 container = input < HTMLElement | ElementRef < HTMLElement | undefined > | undefined > ( ) ;
2830
31+ private document = inject ( DOCUMENT ) ;
2932 private title = inject ( NgtTweakTitle , { host : true } ) ;
3033 private folder = inject ( NgtTweakFolder , { host : true } ) ;
3134 private pane = signal < Pane | null > ( null ) ;
35+ private paneContainer ?: HTMLDivElement ;
3236
3337 constructor ( ) {
3438 this . folder . isSelf = false ;
@@ -41,7 +45,13 @@ export class NgtTweakPane {
4145 } ;
4246
4347 if ( container ) {
44- paneOptions . container = 'nativeElement' in container ? container . nativeElement : container ;
48+ const containerElement = 'nativeElement' in container ? container . nativeElement : container ;
49+ if ( containerElement ) {
50+ this . paneContainer = this . document . createElement ( 'div' ) ;
51+ this . paneContainer . classList . add ( ClassName ( 'dfw' ) ( ) ) ;
52+ containerElement . appendChild ( this . paneContainer ) ;
53+ paneOptions . container = this . paneContainer ;
54+ }
4555 }
4656
4757 const pane = new Pane ( paneOptions ) ;
@@ -54,6 +64,10 @@ export class NgtTweakPane {
5464 const pane = this . pane ( ) ;
5565 if ( ! pane ) return ;
5666
67+ if ( this . paneContainer ) {
68+ this . paneContainer . remove ( ) ;
69+ }
70+
5771 pane . element . remove ( ) ;
5872 } ) ;
5973
0 commit comments