ADJUST TEXT SIZE
If you want to insert dynamic text into your banner, but this text may take, in some cases more space than the space reserved for it in the div, you can use the methodadaptText.
The method adaptText
reduces the font size on a given element, “10” is the accepted minimum size.
The reduction factor optimizes text display and adjust the font size according to the space for the text field.
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:"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.setText(sym.$("myText"), ADventori.data.wording);
ADventori.Display.adaptText(sym.$("myText"),10);
Result :
You want to revitalize and adapt your text directly? The method setAndAdaptText
is 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(sym.$("myText"), ADventori.data.wording,12);
Result
Important : To use the adaptText method, the container which use this method had to exist at the beginning of your timeline.
You can also define the size of your container directly from the method setAndAdaptText
ADventori.Display.setAndAdaptText(sym.$("myText"),ADventori.data.wording, 10, {width :270, height:150});
Résultat :