Set .hidden-input to fixed position so we don't have to move it when the cursor moves

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-03-22 17:29:45 -07:00
parent 9e91790ad3
commit 4c74e2187d
3 changed files with 1 additions and 14 deletions

View File

@@ -196,18 +196,11 @@ describe "Editor", ->
it "moves the cursor to the character at the given row and column", ->
expect(editor.getCursor().position()).toEqual(top: 2 * editor.lineHeight, left: 2 * editor.charWidth)
it "moves the hidden input element to the position of the cursor to prevent scrolling misbehavior", ->
expect(editor.hiddenInput.position()).toEqual(top: 2 * editor.lineHeight, left: 2 * editor.charWidth)
describe "if soft-wrap is enabled", ->
beforeEach ->
setEditorWidthInChars(editor, 20)
editor.setSoftWrap(true)
it "doesn't move the hidden input beyond the right side of the horizontal scroller to prevent chrome from auto-scrolling", ->
editor.setCursorScreenPosition([4, 20])
expect(editor.hiddenInput.position()).toEqual(top: 4 * editor.lineHeight, left: editor.horizontalScroller.width() - editor.charWidth)
describe "when the arrow keys are pressed", ->
it "moves the cursor by a single row/column", ->
editor.trigger keydownEvent('right')

View File

@@ -141,12 +141,6 @@ class Editor extends View
@hiddenInput.on "textInput", (e) =>
@insertText(e.originalEvent.data)
@on 'cursor:position-changed', =>
position = @pixelPositionForScreenPosition(@cursor.getScreenPosition())
if @softWrap
position.left = Math.min(position.left, @horizontalScroller.width() - @charWidth)
@hiddenInput.css(position)
@horizontalScroller.on 'scroll', =>
if @horizontalScroller.scrollLeft() == 0
@gutter.removeClass('drop-shadow')

View File

@@ -73,7 +73,7 @@
}
.editor .hidden-input {
position: absolute;
position: fixed;
z-index: -1;
top: 0;
left: 0;