mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
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:
@@ -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?
|
||||
|
||||
13
src/scrollbar-corner-component.coffee
Normal file
13
src/scrollbar-corner-component.coffee
Normal 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
|
||||
Reference in New Issue
Block a user