Skip to content

Scrollable Text Box

Simon Tharby edited this page Sep 28, 2020 · 4 revisions

scroll_text_box

Fixed height (in text lines), which can be specified.
Paragraphs can be specified &/or set dynamically.
"<br />" = blank line.
Each paragraph will be allocated an id, enabling update or styling of text for specific paragraph(s).
lines (height) and paragraphs will default to 1 and [] respectively, if not include in args.

Format:

addScrollText(name, parent, paragraphs, lines)

Example usage (see uiLayout.js for more examples):

let parent = document.getElementById("ui-container");

addScrollText(
  "scroll_A",
  parent,
  ["This is a scrollable text box.",
   "<br />",
   "It has a fixed height and is useful when a variable quantity of text may be output to the text box.",
   "Each paragraph is given an id value and thus can be styled &/or updated individually."],
  4
);

Example of generated HTML:

<div class="scroll-box scroll" id="scroll_A" style="height: 90px;">
  <p id="scroll_A_0">This is a scrollable text box.</p>
  <p id="scroll_A_1"><br></p>
  <p id="scroll_A_2">It has a fixed height and is useful when a variable quantity of text may be output to the text box.</p>
  <p id="scroll_A_3">Each paragraph is given an id value and thus can be styled &amp;/or updated individually.</p>
</div>
Clone this wiki locally