Sha256: dc2d88e46b7e5b1b7032ee6d37d0b6dfa16e3f6a76c0eb9e32e180c058775438
Contents?: true
Size: 1.13 KB
Versions: 26
Compression:
Stored size: 1.13 KB
Contents
smoothScroll = -> $('a[href*=#]').click -> anchor = $(this).attr('href').match(/#(.*)/)[1] target = $('a[name=' + anchor + ']') ran = false $('html, body').animate { scrollTop: target.offset().top - 60 }, 400, -> unless ran offset = this.scrollTop location.hash = anchor this.scrollTop = offset ran = true false highlightNav = -> anchors = $('h2 a[name]') anchor_links = $('ul a') positions = anchors.map (i, item) -> $(item).offset().top anchors = $.makeArray(anchors).reverse() anchor_links = $.makeArray(anchor_links).reverse() positions = $.makeArray(positions).reverse() scrollHappened = -> anchor_index = null scroll_y = this.scrollY $.each positions, (i, item) -> if scroll_y >= item - 70 anchor_index = i return false if anchor_index? $(anchor_links).removeClass 'selected' $(anchor_links[anchor_index]).addClass 'selected' if scroll_y < positions[positions.length - 1] - 70 $(anchor_links).removeClass 'selected' $(window).scroll scrollHappened scrollHappened() $ -> smoothScroll() highlightNav()
Version data entries
26 entries across 26 versions & 1 rubygems