You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* supports any font family and size, as well as text-transforms
22
27
* the text area can have arbitrary padding or borders
23
28
* not confused by horizontal or vertical scrollbars in the textarea
24
29
* supports hard returns, tabs (except on IE) and consecutive spaces in the text
25
30
* correct position on lines longer than the columns in the text area
26
-
* no ["ghost" position in the empty space](https://github.com/component/textarea-caret-position/blob/06d2197f85f96405b43724e56dc56f220c0092a5/test/position_off_after_wrapping_with_whitespace_before_EOL.gif) at the end of a line when wrapping long words
31
+
*[no problem](http://archive.today/F4XCV#13402035) getting the correct position when the input text is scrolled (i.e. the first visible character is no longer the first in the text)
32
+
* no ["ghost" position in the empty space](https://github.com/component/textarea-caret-position/blob/06d2197f85f96405b43724e56dc56f220c0092a5/test/position_off_after_wrapping_with_whitespace_before_EOL.gif) at the end of a line when wrapping long words in a `<textarea>`
27
33
28
34
29
35
## API
@@ -38,15 +44,15 @@ document.querySelector('textarea').addEventListener('input', function () {
38
44
})
39
45
```
40
46
41
-
### var coordinates = getCaretCoordinates(textarea, position)
47
+
### var coordinates = getCaretCoordinates(element, position)
42
48
43
49
`position` is a integer of the location of the caret. You basically pass `this.selectionStart` or `this.selectionEnd`. This way, this library isn't opinionated about what the caret is.
44
50
45
51
`coordinates` is an object of the form `{top: , left: }`.
46
52
47
53
## Known issues
48
54
49
-
* Tab characters aren't supported in IE9 (issue #14)
55
+
* Tab characters in `<textarea>`s aren't supported in IE9 (issue #14)
50
56
51
57
## Dependencies
52
58
@@ -81,8 +87,8 @@ Firefox 27
81
87
82
88
## Contributors
83
89
84
-
* Jonathan Ong ([jonathanong](https://github.com/jonathanong))
85
90
* Dan Dascalescu ([dandv](https://github.com/dandv))
91
+
* Jonathan Ong ([jonathanong](https://github.com/jonathanong))
// the second special handling for input type="text" vs textarea: spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037
0 commit comments