From 7d2d0f2037b851a7855ccbc563309f84abbab8c8 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 13 Mar 2012 16:09:11 -0600 Subject: [PATCH] Add a drop shadow to gutter when horizontal scroller is scrolled right. --- spec/atom/editor-spec.coffee | 15 +++++++++++++++ src/atom/editor.coffee | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/spec/atom/editor-spec.coffee b/spec/atom/editor-spec.coffee index 48c8f789c..ee619452f 100644 --- a/spec/atom/editor-spec.coffee +++ b/spec/atom/editor-spec.coffee @@ -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})", -> diff --git a/src/atom/editor.coffee b/src/atom/editor.coffee index d08ae90a1..697bac867 100644 --- a/src/atom/editor.coffee +++ b/src/atom/editor.coffee @@ -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)