2

Heyy guys.

First of all, I'm not trying to detect a \n in a text node. What I need to know is when/where a text will wrap to the other line.

My idea was to iterate over the TextNode, letter by letter, create a new TextNode compound of all letters until the current step, after that I would calculate the height of the text node, if the height of the current step is different from the previous one, then the line wrapped.

The problem is I'm having a hard time to figure out the height of the current text. This is what I have so far: http://jsfiddle.net/mfnAT/2/

You can see that the height returned by getTextNodeHeight is incorrect and I don't know what is wrong. I found this function here.

Any of you guys know how to solve this? Or a better approach for this problem?

Community
  • 1
  • 1
lucaswxp
  • 2,031
  • 5
  • 23
  • 34

1 Answers1

0

Set a coordinate somewhere in the middle of your text. call the left offset relative to this position at a given time interval measured by setTimeout. Initialize one event listener on page load that listens for the left offset to be negative ( meaning it is now to the right of this position) That event listener simply Initializes a second event listener that listens for the left offset to be positive, which would symbolize a \n. Call the two event listeners back and forth. I will be back on in a few hours if you have questions.

Four_lo
  • 1,150
  • 10
  • 28
  • Yeah, I didn't understand. Any examples? =) – lucaswxp Mar 21 '13 at 17:26
  • Yeah I am not good with explaining, I will add in some code. I just wanted to know what happens when you get an /n occurance. just in general like run a function or what? – Four_lo Mar 21 '13 at 18:21