updating pagemenu logic so icon is next to element but only shows if it's not anchored to the top. this should more cleanly resolve freemarker/docgen#16
diff --git a/src/main/org/freemarker/docgen/less/lib/layout/content.less b/src/main/org/freemarker/docgen/less/lib/layout/content.less
index d1ba01e..6341ee6 100644
--- a/src/main/org/freemarker/docgen/less/lib/layout/content.less
+++ b/src/main/org/freemarker/docgen/less/lib/layout/content.less
@@ -118,23 +118,22 @@
.content-header {
&::before {
.icon();
- .icon-arrow-right();
+ .icon-star();
margin-left: -18px;
- margin-top: -30px;
+ margin-top: 2px;
width: 18px;
font-weight: normal;
- font-size: 27px;
+ font-size: 18px;
color: #C82222;
float: left;
-
visibility: hidden;
- transform: rotate(45deg);
+ //transform: rotate(45deg);
@media (min-width: @screen-sm-min) {
- margin-left: -35px;
+ margin-left: -24px;
}
}
}
diff --git a/src/main/org/freemarker/docgen/statics/page-menu.js b/src/main/org/freemarker/docgen/statics/page-menu.js
index 32fabfa..a47fb0f 100644
--- a/src/main/org/freemarker/docgen/statics/page-menu.js
+++ b/src/main/org/freemarker/docgen/statics/page-menu.js
@@ -1,4 +1,12 @@
(function() {
+ function isAtTop(node) {
+ var parent = node.offsetParent;
+ var nodeOffsetTop = node.offsetTop + node.offsetParent.offsetTop - 5;
+ var windowOffsetTop = window.pageYOffset;
+
+ // @todo: figure out why less than isn't working when they are equal
+ return (nodeOffsetTop === windowOffsetTop || nodeOffsetTop < windowOffsetTop);
+ }
// remove highlight class so animation can be repeated on same node again
function unHighlightNode(nodeId) {
@@ -12,13 +20,16 @@
function highlightNode(nodeId) {
var node = document.getElementById(nodeId);
- if (node) {
- node.classList.add('active');
+ // wrap in a setTimeout so that window.scrollY is accurate when we poll it
+ window.setTimeout(function() {
+ if (node && !isAtTop(node)) {
+ node.classList.add('active');
- window.setTimeout(function() {
- unHighlightNode(nodeId);
- }, 1000);
- }
+ window.setTimeout(function() {
+ unHighlightNode(nodeId);
+ }, 1000);
+ }
+ }, 1);
}
function onPageMenuClick(e) {