aboutsummaryrefslogtreecommitdiffstats
path: root/app/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/referential_overview/index.coffee23
1 files changed, 22 insertions, 1 deletions
diff --git a/app/javascript/referential_overview/index.coffee b/app/javascript/referential_overview/index.coffee
index 6128d7c98..c9a266dea 100644
--- a/app/javascript/referential_overview/index.coffee
+++ b/app/javascript/referential_overview/index.coffee
@@ -38,6 +38,8 @@ class window.ReferentialOverview
@container = $(selector)
@timeTravel = new TimeTravel(this)
@currentOffset = 0
+ $(document).scroll (e)=>
+ @documentScroll(e)
showDay: (date)->
day = @container.find(".day.#{date}")
@@ -48,6 +50,11 @@ class window.ReferentialOverview
currentOffset: ->
@container.find(".right .inner").offset().left
+ top: ->
+ @_top ||= @container.find('.days').offset().top - 80
+ bottom: ->
+ @_bottom ||= @top() + @container.height() - 50
+
prevPage: ->
@scrollTo @currentOffset + @container.find(".right").width()
@@ -62,7 +69,21 @@ class window.ReferentialOverview
@currentOffset = offset
@currentOffset = Math.max(@currentOffset, @minOffset())
@currentOffset = Math.min(@currentOffset, 0)
- @container.find(".right .inner").css "margin-left": "#{@currentOffset}px"
+ @container.find(".right .inner .lines").css "margin-left": "#{@currentOffset}px"
+ @container.find(".head .week:first-child").css "margin-left", "#{@currentOffset}px"
@timeTravel.scrolledTo 1 - (@minOffset() - @currentOffset) / @minOffset()
+
+ documentScroll: (e)->
+ if @sticky
+ if e.pageY < @top() || e.pageY > @bottom()
+ @container.removeClass "sticky"
+ @sticky = false
+ else
+ if e.pageY > @top() && e.pageY < @bottom()
+ @sticky = true
+ @container.addClass "sticky"
+
+
+
export default ReferentialOverview