aboutsummaryrefslogtreecommitdiffstats
path: root/app/javascript
diff options
context:
space:
mode:
authorZog2018-01-19 12:18:12 +0100
committerZog2018-02-02 14:31:43 +0100
commitefda80f4bb90cc5bc8d090c260ba2ac54869e121 (patch)
tree77ace28a76090301aaeb31e8b7b6f4edf627c9ae /app/javascript
parentb85f33cbf055633fab4d320f1a926e319626a9f5 (diff)
downloadchouette-core-efda80f4bb90cc5bc8d090c260ba2ac54869e121.tar.bz2
Refs #3542 @1h; Add sticky header
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