This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Kristian Hjelle
Posted Mar 01 - Read on Facebook

Is there a good practice for getting the height of HTML content in Framer?

Example: I'm making a prototype that pulls in data (articles) from an API. I list these results in a scroll view where I display the headline and image from the article. Clicking the articles opens up a detail view, where I display the body text of the article. The length of the body text varies from article to article. I want to calculate the height of this content—then use that value to set the height of the detail view.


Panos Spiliotis

This is such a good and simple solution for a very frequently needed value that it should be considered as an addition to the native app methods for Layer.

Benjamin Den Boer may work here.

Kristian Hjelle

Hmm, that doesn't seem to help. It only returns "100px" (if I don't set a height value prior to that) or the value I set when creating the layer.

Kristian Hjelle

Turns out I can just set the text layers' height to auto, like this: ' = "auto"' and that'll make it work like I want it to!

Kristian Hjelle

A little tip if anyone else has use for this. To use that height value later, you have to get the computed style, if not it'll just return "auto":

myVariableRaw = myTextLayer.computedStyle()["height"]

...and then use regex to clean out the "px" suffix:

myVariable = myVariableRaw.replace(/[px]\w+/g, '')

Read the entire post on Facebook