1
+ import { DOCUMENT } from '@angular/common' ;
1
2
import {
2
3
afterNextRender ,
3
4
DestroyRef ,
@@ -9,6 +10,7 @@ import {
9
10
isSignal ,
10
11
signal ,
11
12
} from '@angular/core' ;
13
+ import { ClassName } from '@tweakpane/core' ;
12
14
import { Pane } from 'tweakpane' ;
13
15
import { PaneConfig } from 'tweakpane/dist/types/pane/pane-config' ;
14
16
import { NgtTweakFolder } from './folder' ;
@@ -26,9 +28,11 @@ export class NgtTweakPane {
26
28
width = input < string | number > ( '256px' ) ;
27
29
container = input < HTMLElement | ElementRef < HTMLElement | undefined > | undefined > ( ) ;
28
30
31
+ private document = inject ( DOCUMENT ) ;
29
32
private title = inject ( NgtTweakTitle , { host : true } ) ;
30
33
private folder = inject ( NgtTweakFolder , { host : true } ) ;
31
34
private pane = signal < Pane | null > ( null ) ;
35
+ private paneContainer ?: HTMLDivElement ;
32
36
33
37
constructor ( ) {
34
38
this . folder . isSelf = false ;
@@ -41,7 +45,13 @@ export class NgtTweakPane {
41
45
} ;
42
46
43
47
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
+ }
45
55
}
46
56
47
57
const pane = new Pane ( paneOptions ) ;
@@ -54,6 +64,10 @@ export class NgtTweakPane {
54
64
const pane = this . pane ( ) ;
55
65
if ( ! pane ) return ;
56
66
67
+ if ( this . paneContainer ) {
68
+ this . paneContainer . remove ( ) ;
69
+ }
70
+
57
71
pane . element . remove ( ) ;
58
72
} ) ;
59
73
0 commit comments