Put the hidden input in the overlayer

The overlayer is absolutely positioned to exactly fill the scroll-view.
If we can retain this strategy and never give the input a position that
exceeds the bounds of the overlayer, we can guarantee that it never
forces the scroll position of the scroll view to change when it is
focused due to the browsers default behavior.
This commit is contained in:
Nathan Sobo
2014-04-01 13:33:20 -06:00
parent e4c1bf10f5
commit 61d9ff4ba4

View File

@@ -13,7 +13,8 @@ React.createClass
render: ->
div className: 'editor',
div className: 'scroll-view', ref: 'scrollView',
div className: 'overlayer'
div className: 'overlayer',
InputComponent ref: 'hiddenInput', className: 'hidden-input', onInput: @onInput
@renderVisibleLines()
div className: 'vertical-scrollbar', ref: 'verticalScrollbar', onScroll: @onVerticalScroll,
div outlet: 'verticalScrollbarContent', style: {height: @getScrollHeight()}
@@ -25,7 +26,6 @@ React.createClass
followingHeight = (lineCount - endRow) * @state.lineHeight
div className: 'lines', ref: 'lines', style: {WebkitTransform: "translateY(#{-@state.scrollTop}px)"}, [
InputComponent ref: 'hiddenInput', onInput: @onInput
div className: 'spacer', key: 'top-spacer', style: {height: precedingHeight}
(for tokenizedLine in @props.editor.linesForScreenRows(startRow, endRow - 1)
LineComponent({tokenizedLine, key: tokenizedLine.id}))...
@@ -120,7 +120,7 @@ LineComponent = React.createClass
InputComponent = React.createClass
render: ->
input @props.className, ref: 'input'
input className: @props.className, ref: 'input'
getInitialState: ->
{lastChar: ''}