1

As per requirement, I need to scroll horizontal text with specific size consider I have text with 60 character and display area size is 40 then result should be

  1. Need to display 42 character and then start scroll for remaining 18 characters
  2. Then place that 1st 42 character alone

I tried with marquee but unable to fit exact size with below sample code

if (nameText.length >= 42) {
  oldStr = $("#Guide-Info-Title", m_jQInfo).html();
  oldStr = oldStr.replace(/\<marquee>/g, "");
  oldStr = oldStr.replace(/<\/marquee>/g, "");
  $("#Guide-Info-Title", m_jQInfo).html(oldStr);

  oldStr = nameText + '&emsp;' + '&emsp;';
  NewStr = oldStr + nameText.substr(0, 42);

  $("#Guide-Info-Title", m_jQInfo).html("<marquee behavior=alternate direction=left loop=1 scrolldelay=10>" + NewStr + "</marquee>");
}

Anyone please help me to achieve my requirement?

Saeed
  • 5,413
  • 3
  • 26
  • 40
dhan
  • 11
  • 2
  • The optical size might always differ depending on the text if the text is not written in mono-space-font. You can compare `iiiii` and `mmmmm`, the length is different. So you had to stick perhaps to the defined width of the outer container. – David Jun 10 '18 at 09:24
  • Hi I got your point about non mono-soace font but i'm not aware to control via outer container for this scrolling, could you help me – dhan Jun 11 '18 at 07:59
  • mhm, then you've to check the computed size of the area, is possible too And if too small reduce the text-length. Also consider that you might not want to reduce letter by letter till the available size is reached, but that you want to reduce word by word probably. – David Jun 11 '18 at 09:06
  • Have a look here, don't know now why the answer is down-voted and if it'*s useful: https://stackoverflow.com/questions/9865306/find-the-width-of-an-auto-sized-element/9865360#9865360 Else just search for something resembling. – David Jun 11 '18 at 09:11

0 Answers0