 
       @setState lastScrollY: null
     else
-      scrollY = if @props.anchor? then $(@props.anchor.current).offset().top else 0
+      scrollY = if @props.anchor?.current? then $(@props.anchor.current).offset().top else 0
       if window.pageYOffset > scrollY
         @setState lastScrollY: window.pageYOffset
 

    if window.IntersectionObserver?
      return if @observer?

      options =
        root: null
        rootMargin: '0px'


      callback = (entries) =>
        for entry in entries
          if entry.target == target && entry.boundingClientRect.top == 0
            # also gets attached when scrolling downwards, but should be fine in this case.
            document.addEventListener 'scroll', @onScroll
            break

      @observer = new IntersectionObserver(callback, options)
      @observer.observe(target)
    else
      Timeout.set 0, () =>
        document.addEventListener 'scroll', @onScroll
