diff --git a/assets/scripts/app/tailing.coffee b/assets/scripts/app/tailing.coffee index a9be33df..3df8c872 100644 --- a/assets/scripts/app/tailing.coffee +++ b/assets/scripts/app/tailing.coffee @@ -51,8 +51,13 @@ class @Travis.Tailing return if @tail().length is 0 offset = @window.scrollTop() - @log().offset().top max = @log().height() - @tail().height() + 5 - offset = max if offset > max - if offset > 0 + + if offset > 0 && offset <= max + @tail().removeClass('bottom') @tail().addClass('scrolling') else + if offset > max + @tail().addClass('bottom') + else + @tail().removeClass('bottom') @tail().removeClass('scrolling') diff --git a/assets/scripts/spec/unit/tailing_spec.coffee b/assets/scripts/spec/unit/tailing_spec.coffee index a3d59125..18a836f0 100644 --- a/assets/scripts/spec/unit/tailing_spec.coffee +++ b/assets/scripts/spec/unit/tailing_spec.coffee @@ -71,8 +71,19 @@ test 'positionButton adds the scrolling class', -> tail.positionButton() equal(element.hasClass('scrolling'), true) + equal(element.hasClass('bottom'), false) test 'positionButton removes the scrolling class', -> log.offset = -> {top: 1} tail.positionButton() equal(element.hasClass('scrolling'), false) + equal(element.hasClass('bottom'), false) + +test 'positionButton sets the button as bottom', -> + log.offset = -> {top: -100} + log.height = -> 50 + tail.height = -> 1 + + tail.positionButton() + equal(element.hasClass('scrolling'), false) + equal(element.hasClass('bottom'), true) diff --git a/assets/styles/main/log.sass b/assets/styles/main/log.sass index c88a8dcf..2e0ad5ff 100644 --- a/assets/styles/main/log.sass +++ b/assets/styles/main/log.sass @@ -121,6 +121,10 @@ pre#log position: fixed right: 32px + &.bottom + bottom: 45px + top: inherit + .status display: inline-block margin-right: 1px