 staticNav = d3.select("#nav")
 navList = d3.selectAll(".nav-list")
 sticky = false
+doc = document.documentElement
 
 toggleSticky = ->
-  if not sticky and win.scrollTop > hero.offsetHeight
+  top = (window.pageYOffset || doc.scrollTop)  - (doc.clientTop || 0)
+  if not sticky and top > hero.offsetHeight
     nav.classed "hidden", false
     sticky = true
-  else if sticky and win.scrollTop <= hero.offsetHeight
+  else if sticky and top <= hero.offsetHeight
     nav.classed "hidden", true
     sticky = false
 


getSectionId = ->
  winHeight = win.offsetHeight
  midScroll = win.scrollTop + winHeight * 0.5
  offset = null
  section = "cyberpunk"
  for el in sections[0]

  scrollTo(navPos)

scrollTo = (pos) ->
  if (window.pageYOffset || doc.scrollTop)  - (doc.clientTop || 0) < pos
    document.documentElement.scrollTop += 20
    setTimeout ->
      scrollTo(pos)
    , 5
