(router)
| 94 | } |
| 95 | |
| 96 | export function scrollActiveSidebar(router) { |
| 97 | const cover = dom.find('.cover.show'); |
| 98 | coverHeight = cover ? cover.offsetHeight : 0; |
| 99 | |
| 100 | const sidebar = dom.getNode('.sidebar'); |
| 101 | let lis = []; |
| 102 | if (sidebar !== null && sidebar !== undefined) { |
| 103 | lis = dom.findAll(sidebar, 'li'); |
| 104 | } |
| 105 | |
| 106 | for (let i = 0, len = lis.length; i < len; i += 1) { |
| 107 | const li = lis[i]; |
| 108 | const a = li.querySelector('a'); |
| 109 | if (!a) { |
| 110 | continue; |
| 111 | } |
| 112 | |
| 113 | let href = a.getAttribute('href'); |
| 114 | |
| 115 | if (href !== '/') { |
| 116 | const { |
| 117 | query: { id }, |
| 118 | path, |
| 119 | } = router.parse(href); |
| 120 | if (id) { |
| 121 | href = getNavKey(path, id); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | if (href) { |
| 126 | nav[decodeURIComponent(href)] = li; |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | if (isMobile) { |
| 131 | return; |
| 132 | } |
| 133 | |
| 134 | const path = removeParams(router.getCurrentPath()); |
| 135 | dom.off('scroll', () => highlight(path)); |
| 136 | dom.on('scroll', () => highlight(path)); |
| 137 | dom.on(sidebar, 'mouseover', () => { |
| 138 | hoverOver = true; |
| 139 | }); |
| 140 | dom.on(sidebar, 'mouseleave', () => { |
| 141 | hoverOver = false; |
| 142 | }); |
| 143 | } |
| 144 | |
| 145 | export function scrollIntoView(path, id) { |
| 146 | if (!id) { |
no test coverage detected
searching dependent graphs…