forked from kir/js_cursor_position
-
Notifications
You must be signed in to change notification settings - Fork 0
A small library which allows to detect cursor position in Javascript textarea
othree/js_cursor_position
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Javascript cursor position in a textarea or textfield ===================================================== Essence ------- To obtain the text cursor position in textarea or in textfield. Cursor position is provided either in characters, or in pixes relative to top left corner of the textarea. Why --- The library can be used for positioning of a completion popup window in a textarea or input text field right near current text cursor. Given that long text is wrapped in the textarea, the task is not very trivial. How --- The library tries to model text wrapping in the textarea and to find out relative cursor position. The results are not 100% accurate, but really close to it. Usage: var positioner = new maxkir.CursorPosition(textarea_element, 3); alert(positioner.getCursorCoordinates()); // [x, y] position of cursor in textarea in characters alert(positioner.getPixelCoordinates()); // [x, y] position of cursor in textarea in pixels See also functional test under test/cursor_position_test.html Dependencies ------------ None, plain javascript code -- Copyright (c) 2010 Kirill Maximov, released under the MIT license
About
A small library which allows to detect cursor position in Javascript textarea
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published