Expanding textfield to flexible height

is it possible in hype to place a text field, which is fitting to height, depending how much text it is used,
like in html
<div>test</div>?
i get always fixed height or scrollable text. also if i use innerHTML
<div>test</div>
it is set to hypes defined textfield-height.
the reason is, i get text-data from a database loading into a hype textfield.
so sometimes i get more, sometimes less text. therefore the textfield should be flexible in it´s height.

maby anyone has eperiences with this issue?

Check out this solution:

2 Likes

thanks @Daniel - i get a working example. i´m going to post this on tipps and tricks :champagne:

2 Likes

Hi Daniel,

Is there any chance this feature gets supported by Hype without loading a 277kB of a jQuerry library? Realistically this is not an option for majority of advertising creatives, which are limited in file weight.

Just run this hype function extension on you element

	/** 
	* hypeDocument.setHeightToContent
	* @param {HTMLDivElement} element to fix height on
	*/
	hypeDocument.setHeightToContent = function (elm) {
	    var overflow = elm.style.overflow;
	    elm.style.overflow = 'hidden';
	   	hypeDocument.setElementProperty(elm, 'height', 0);
	   	hypeDocument.setElementProperty(elm, 'height', elm.scrollHeight);
	   	elm.style.overflow = overflow; 
	}

The following is an example file using this but also targeting the nodes with a dataset attribute. That’s totally optional. Example moved to next answer…

I added some different examples in this version and added a fix (also above):

Demo:
FixHeightExample.html

Download of example:
FixHeightExample.hype.zip

1 Like

Thanks man, really appreciate it. I will test it out early next week as I got some other urgent stuff to release.

@MaxZieb hi,

i have a problem with expanding textfield when i call text from json file. In my case flexible height doesn't work anymore. If i manualy insert custom text, than works normaly. Is there any solution?

Thx

There can only be a solution if the problem is clear. Please provide a file that contains your problem in an isolated fashion.

A post was split to a new topic: Loading JSON files from the resource folder