christianp / writemaths

A jQuery plugin to give an instant preview of LaTeX in editing areas.
http://christianp.github.io/writemaths
27 stars 7 forks source link

Why return if pos.y < 0? #3

Open jpslav opened 10 years ago

jpslav commented 10 years ago

On line 157 the code returns if the y position is less than 0. Why do this? With this in there the preview won't show up for any math on the first line of my textarea.

Now I'm thinking this probably has something to do with the fact that I switched out the caret position finder (see my comment on #2). I bet the old way gave the position at the bottom of the line of text, whereas my new way doesn't so when the code subtracts the font-size now it can get a negative number.

https://github.com/christianp/writemaths/blob/master/writemaths.js#L157

christianp commented 10 years ago

Hi JP, As it happens, I've been updating writemaths this week. The position-getting code is a total mess now, since jQuery deprecated the methods I relied on. I've decided to remove the option to position the preview above the cursor. In @numbas, we switched to positioning the preview on top of the edit area anyway, because when it was above the cursor it was covering up the text being edited!

Do you specifically want to put the preview above the cursor, or is this OK?

jpslav commented 10 years ago

Hey Christian -

Probably ok to not have it be above the cursor, but it is kind of nice to have it close to where you are typing (so you can see it right when typing the math instead of going back and forth). I think some of my users will be writing longer bits of text so the distance between their cursor and the top of the editor might be a bit big.

Re the problem of the preview covering the text, you might also consider putting the preview right above the opening symbol of the latex statement (e.g. right above the "$"). That way it is near to the actual editing without covering the math. Also it wouldn't move with each keystroke.

JP

On Dec 5, 2013, at 2:17 AM, Christian Perfect notifications@github.com wrote:

Hi JP, As it happens, I've been updating writemaths this week. The position-getting code is a total mess now, since jQuery deprecated the methods I relied on. I've decided to remove the option to position the preview above the cursor. In @numbas, we switched to positioning the preview on top of the edit area anyway, because when it was above the cursor it was covering up the text being edited!

Do you specifically want to put the preview above the cursor, or is this OK?

— Reply to this email directly or view it on GitHub.

christianp commented 10 years ago

Didn't it used to go over the opening symbol? Maybe not. Anyway, it's more of a problem that it covers the surrounding text, rather than the maths.

You can position the preview relative to the screen instead of the edit area - set the of option to window.document when initialising the writemaths area.