Add a dummy scrollbar corner

Horizontal / vertical scrollbars render a 'corner' on the lower right
when they would otherwise overlap. I previously relied on drawing both
dummy scrollbars at their full width/height so the corner got rendered,
but that interfered with the display of the horizontal scrollbar in
certain circumstances because it was too wide to scroll. This commit
provides that behavior with an absolutely positioned div with the same
dimensions as the intersection of scrollbars when both are visible.
This commit is contained in:
Nathan Sobo
2014-05-02 03:15:42 -07:00
parent 5e6d91d66c
commit ab1ede5fe6
4 changed files with 35 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ React = require 'react'
GutterComponent = require './gutter-component'
EditorScrollViewComponent = require './editor-scroll-view-component'
ScrollbarComponent = require './scrollbar-component'
ScrollbarCornerComponent = require './scrollbar-corner-component'
SubscriberMixin = require './subscriber-mixin'
module.exports =
@@ -36,6 +37,8 @@ EditorComponent = React.createClass
lineHeightInPixels = editor.getLineHeight()
horizontalScrollbarHeight = editor.getHorizontalScrollbarHeight()
verticalScrollbarWidth = editor.getVerticalScrollbarWidth()
verticallyScrollable = editor.verticallyScrollable()
horizontallyScrollable = editor.horizontallyScrollable()
className = 'editor editor-colors react'
className += ' is-focused' if focused
@@ -61,7 +64,7 @@ EditorComponent = React.createClass
onScroll: @onVerticalScroll
scrollTop: scrollTop
scrollHeight: scrollHeight
scrollableInOppositeDirection: editor.horizontallyScrollable() if @isMounted()
scrollableInOppositeDirection: horizontallyScrollable
horizontalScrollbarHeight: horizontalScrollbarHeight
ScrollbarComponent
@@ -71,9 +74,14 @@ EditorComponent = React.createClass
onScroll: @onHorizontalScroll
scrollLeft: scrollLeft
scrollWidth: scrollWidth + @gutterWidth
scrollableInOppositeDirection: editor.verticallyScrollable() if @isMounted()
scrollableInOppositeDirection: verticallyScrollable
verticalScrollbarWidth: verticalScrollbarWidth
ScrollbarCornerComponent
visible: horizontallyScrollable and verticallyScrollable
height: horizontalScrollbarHeight
width: verticalScrollbarWidth
getRenderedRowRange: ->
renderedRowRange = @props.editor.getVisibleRowRange()
if @preservedRowRange?

View File

@@ -0,0 +1,13 @@
React = require 'react'
{div} = require 'reactionary'
module.exports =
ScrollbarComponent = React.createClass
render: ->
{visible, width, height} = @props
display = 'none' unless visible
div className: 'scrollbar-corner', style: {display, width, height},
div style:
height: height + 1
width: width + 1