vdolek / angular-resize-event

Angular directive for detecting changes of an element size.
MIT License
169 stars 62 forks source link

SSR: ResizeObserver is not defined #61

Open schulzi66 opened 2 years ago

schulzi66 commented 2 years ago

When serving an angular application with SSR, the directive breaks the application, due to the following error: ReferenceError: ResizeObserver is not defined

It seems that the error occours in the constructor of the directive.

schulzi66 commented 2 years ago

A solution would be to use the isPlatformServer() from @angular/common to check if the application is running in SSR and if so, not initialize the ResizeObserver

cotz1995 commented 2 years ago

I'm also experiencing this issue when using prerendering.

It looks like this is solved in https://github.com/vdolek/angular-resize-event/pull/62

EDIT: added link to solution PR