Skip to content

Commit 821fa55

Browse files
committed
fix: use a div instead of ngt-canvas-container component
1 parent 57d71b5 commit 821fa55

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

libs/angular-three/src/lib/canvas.ts

+9-27
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
ViewChild,
1717
ViewContainerRef,
1818
} from '@angular/core';
19-
import { injectNgxResize, NgxResizeResult, provideNgxResizeOptions } from 'ngx-resize';
19+
import { NgxResize, NgxResizeResult, provideNgxResizeOptions } from 'ngx-resize';
2020
import { filter } from 'rxjs';
2121
import { injectNgtLoader } from './loader';
2222
import { provideNgtRenderer } from './renderer/provider';
@@ -26,36 +26,16 @@ import type { NgtCanvasInputs, NgtDomEvent, NgtDpr, NgtState } from './types';
2626
import { is } from './utils/is';
2727
import { createPointerEvents } from './web/events';
2828

29-
@Component({
30-
selector: 'ngt-canvas-container',
31-
standalone: true,
32-
template: '<ng-content />',
33-
styles: [
34-
`
35-
:host {
36-
display: block;
37-
width: 100%;
38-
height: 100%;
39-
}
40-
`,
41-
],
42-
providers: [provideNgxResizeOptions({ emitInZone: false })],
43-
})
44-
export class NgtCanvasContainer {
45-
@Output() canvasResize = injectNgxResize();
46-
}
47-
4829
@Component({
4930
selector: 'ngt-canvas',
5031
standalone: true,
5132
template: `
52-
<ngt-canvas-container (canvasResize)="onResize($event)">
33+
<div (ngxResize)="onResize($event)" style="height: 100%; width: 100%;">
5334
<canvas #glCanvas style="display: block;"></canvas>
54-
<ng-container #glAnchor />
55-
</ngt-canvas-container>
35+
</div>
5636
`,
57-
imports: [NgtCanvasContainer],
58-
providers: [NgtStore],
37+
imports: [NgxResize],
38+
providers: [NgtStore, provideNgxResizeOptions({ emitInZone: false })],
5939
styles: [
6040
`
6141
:host {
@@ -158,7 +138,7 @@ export class NgtCanvas extends NgtRxStore<NgtCanvasInputs> implements OnInit, On
158138
@Output() pointerMissed = new EventEmitter<MouseEvent>();
159139

160140
@ViewChild('glCanvas', { static: true }) glCanvas!: ElementRef<HTMLCanvasElement>;
161-
@ViewChild('glAnchor', { static: true, read: ViewContainerRef }) glAnchor!: ViewContainerRef;
141+
@ViewChild('glCanvas', { static: true, read: ViewContainerRef }) glAnchor!: ViewContainerRef;
162142

163143
private glRef?: ComponentRef<unknown>;
164144
private glEnvInjector?: EnvironmentInjector;
@@ -242,7 +222,9 @@ export class NgtCanvas extends NgtRxStore<NgtCanvasInputs> implements OnInit, On
242222
],
243223
this.envInjector
244224
);
245-
this.glRef = this.glAnchor.createComponent(this.sceneGraph, { environmentInjector: this.glEnvInjector });
225+
this.glRef = this.glAnchor.createComponent(this.sceneGraph, {
226+
environmentInjector: this.glEnvInjector,
227+
});
246228
this.glRef.changeDetectorRef.detach();
247229

248230
// here, we override the detectChanges to also call detectChanges on the ComponentRef

0 commit comments

Comments
 (0)