Add a drop shadow to gutter when horizontal scroller is scrolled right.

This commit is contained in:
Nathan Sobo 2012-03-13 16:09:11 -06:00
parent 5709b0d152
commit 7d2d0f2037
2 changed files with 21 additions and 0 deletions

View File

@ -161,6 +161,21 @@ describe "Editor", ->
editor.createFold([[3, 10], [5, 1]])
expect(editor.gutter.find('.line-number:eq(3)').text()).toBe '4'
expect(editor.gutter.find('.line-number:eq(4)').text()).toBe '7'
it "adds a drop shadow when the horizontal scroller is scrolled to the right", ->
editor.attachToDom()
editor.width(100)
expect(editor.gutter).not.toHaveClass('drop-shadow')
editor.horizontalScroller.scrollLeft(10)
editor.horizontalScroller.trigger('scroll')
expect(editor.gutter).toHaveClass('drop-shadow')
editor.horizontalScroller.scrollLeft(0)
editor.horizontalScroller.trigger('scroll')
expect(editor.gutter).not.toHaveClass('drop-shadow')
describe "cursor movement", ->
describe ".setCursorScreenPosition({row, column})", ->

View File

@ -127,6 +127,12 @@ class Editor extends View
position.left = Math.min(position.left, @horizontalScroller.width() - @charWidth)
@hiddenInput.css(position)
@horizontalScroller.on 'scroll', =>
if @horizontalScroller.scrollLeft() == 0
@gutter.removeClass('drop-shadow')
else
@gutter.addClass('drop-shadow')
@one 'attach', =>
@calculateDimensions()
@hiddenInput.width(@charWidth)