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

What is Framer? Join the Community
Return to index
David Louie
Posted May 16 - Read on Facebook

How do parse this string into a number in Framer Studio?

In order to get the width of the text entered in a textfield, I created an invisible layer and plumbed in inputElement.value into it. mylayer.width doesn't get the right value for some reason so I've had to use mylayer.computedStyles()['width'] to get the width but that returns a string. How do I trim that into a number here?


Jon Gold


Arron J Hunt

string = "110.734375px"
parsedString = +string.substring(0, string.length-2)

Mike Feldstein


David Louie

Well shizz, that was simple - thanks y'all.

Arron J Hunt

Yikes, I over complicated things 😳

Mike Feldstein

i've never seen the +prefix that's a cool way to do it though.

Katie Castronova

i'm not sure if it's cool- feels like one of those weird JS details

Read the entire post on Facebook