Alternatives from Ionic V3 to V4

Hello everyone,

I hope everyone is doing well.

I’m looking for some assistance upgrading from V3 to V4.

The issue we have is that in IonContent both getContentDimensions and resize methods have been removed in Ionic 4. Is there any other way to get the dimensions of and resize it?

Here is some sample code:

  @ViewChild(IonContent)
  content: IonContent
  const dimensions = this.content.getContentDimensions()
  this.pageHeight = dimensions.contentHeight
      // set height for some charts
	…..
	…..
  this.content.resize()

Thank you all for your assistance.

This shouldn’t be needed anymore since the content size is not determined by JS. It just uses CSS to adjust its size.

If you’re looking to get the height of the Content element though… you could try

  @ViewChild(IonContent, { static: false, read: ElementRef })
  content: ElementRef<HTMLElement>;

  const dimensions = this.content.nativeElement.getBoundingClientRect();

The get the height/width you need from that.

1 Like