ADJUST TEXT SIZE
If you want to insert dynamic text into your creative, but this text may take in some cases, more space than the space reserved for it in the div, you can use the method adaptText.
The method adaptText
reduces the font size on a given element, “10” is the accepted minimum size.
In case the entire text does not fit in the space reserved for it and its font size is 15px, then the method will reduce it to 10px.
Example:
ADventori.initData ( {"wording": "Even though using lorem ipsum often arouses curiosity due to its resemblance to classical Latin, it is not intended to have meaning. Where text is visible in a document, people tend to focus on the textual content rather than upon overall presentation, so publishers use lorem ipsum when displaying a typeface or design in order to direct the focus to presentation"});
ADventori.Format.setText(document.getElementById('wording'), ADventori.data.wording);
ADventori.Display.adaptText(document.getElementById('wording'), 10);
Result :
You want to dynamize and adapt your text directly? The method setAndAdaptText
is made for you :
ADventori.initData({ "wording": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." }); ADventori.Display.setAndAdaptText(document.getElementById('ADventori_text'),ADventori.data.wording,14);
Result
Important : To use the adaptText method, the container which use this method can’t use the CSS property display:none (please use opacity:0;visibility:hidden;)
You can also define the size of your container directly from the method setAndAdaptText
ADventori.Display.setAndAdaptText(document.getElementById('ADventori_text'),ADventori.data.wording, 10, {width :270, height:150});
Résult :