retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
10.17k stars 653 forks source link

Editor is not rendered until window resized #507

Closed serberm closed 1 year ago

serberm commented 3 years ago

I'm using Angular 7.1.4. If I use editor inside components it renders ok, but if pass editor as child to another components with ng-content it does not render Nodes inside editor until window is resized. As a workaround I tried to trigger window resize in ngOnInit:

setTimeout(() => {
            window.dispatchEvent(new Event('resize'));
        });

and it renders nodes but do not render connection lines between sockets

Ni55aN commented 3 years ago

Does the parent element of Rete's container have fixed sizes? Probably at the initialization of the editor, the parent element has zero sizes

serberm commented 3 years ago

Yep, you are right, it had zero sizes. I was initializing container in ngAfterViewInit and found out that not all style properties are attached after ngAfterViewInit event. So the fix was to set timeout

setTimeout(() => { const container = this.el.nativeElement; let editor = new NodeEditor("rivetNodeEditor@0.1.0", container); ... }, 10);

rete-js[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.