Call onScroll with the current scrollTop/Left in ScrollbarComponent

This commit is contained in:
Nathan Sobo
2014-04-14 10:43:57 -06:00
parent 355abef2cf
commit aee552476a
2 changed files with 20 additions and 8 deletions

View File

@@ -308,9 +308,10 @@ EditorCompont = React.createClass
editor.selectLeft() if replaceLastCharacter
editor.insertText(char)
onVerticalScroll: ->
scrollTop = @refs.verticalScrollbar.getDOMNode().scrollTop
return if @props.editor.getScrollTop() is scrollTop
onVerticalScroll: (scrollTop) ->
{editor} = @props
return if scrollTop is editor.getScrollTop()
animationFramePending = @pendingScrollTop?
@pendingScrollTop = scrollTop
@@ -319,9 +320,10 @@ EditorCompont = React.createClass
@props.editor.setScrollTop(@pendingScrollTop)
@pendingScrollTop = null
onHorizontalScroll: ->
scrollLeft = @refs.horizontalScrollbar.getDOMNode().scrollLeft
return if @props.editor.getScrollLeft() is scrollLeft
onHorizontalScroll: (scrollLeft) ->
{editor} = @props
return if scrollLeft is editor.getScrollLeft()
animationFramePending = @pendingScrollLeft?
@pendingScrollLeft = scrollLeft

View File

@@ -7,9 +7,9 @@ ScrollbarComponent = React.createClass
lastScrollLeft: null
render: ->
{orientation, className, onScroll, scrollHeight, scrollWidth} = @props
{orientation, className, scrollHeight, scrollWidth} = @props
div {className, onScroll},
div {className, @onScroll},
switch orientation
when 'vertical'
div className: 'scrollbar-content', style: {height: scrollHeight}
@@ -35,3 +35,13 @@ ScrollbarComponent = React.createClass
unless scrollLeft is @lastScrollLeft
node.scrollLeft = scrollLeft
@lastScrollLeft = node.scrollLeft
onScroll: ->
{orientation, onScroll} = @props
node = @getDOMNode()
switch orientation
when 'vertical'
onScroll(node.scrollTop)
when 'horizontal'
onScroll(node.scrollLeft)