more fixes to scroll offset for the sticky header.

This offsets the layout position of all <a name=""> tags so they naturally
show up below the sticky nav bar... though this is only for API reference,
which uses <a> tags as anchors for all API members.
bug: 16924057

Change-Id: I88c1e8192f1cbb5373af592b9e9f9a04ffe6fc7c
This commit is contained in:
smain@google.com 2014-10-03 09:25:59 -07:00 committed by Scott Main
parent 83fadade5b
commit 9a818f55f4
6 changed files with 20 additions and 7 deletions

View File

@ -4206,6 +4206,14 @@ EndColorStr='#ececec');
z-index: 52; z-index: 52;
} }
/* offset the <a name=""> tags in reference to account for sticky nav */
body.reference a[name] {
visibility: hidden;
display: block;
position: relative;
top: -56px;
}
} }

View File

@ -2535,16 +2535,13 @@ google.setOnLoadCallback(function(){
} }
}, true); }, true);
/* Adjust the scroll position to account for sticky header, only if the hash matches an id */ /* Adjust the scroll position to account for sticky header, only if the hash matches an id.
This does not handle <a name=""> tags. Some CSS fixes those, but only for reference docs. */
function offsetScrollForSticky() { function offsetScrollForSticky() {
var hash = escape(location.hash.substr(1)); var hash = escape(location.hash.substr(1));
var $matchingElement = $("#"+hash); var $matchingElement = $("#"+hash);
// If there's no element with the hash as an ID, then look for an <a name=''> with it. // Sanity check that hash is a real hash and that there's an element with that ID on the page
if ($matchingElement.length < 1) { if ((hash.indexOf("#") == 0) && $matchingElement.length) {
$matchingElement = $('a[name="' + hash + '"]');
}
// Sanity check that there's an element with that ID on the page
if ($matchingElement.length) {
// If the position of the target element is near the top of the page (<20px, where we expect it // If the position of the target element is near the top of the page (<20px, where we expect it
// to be because we need to move it down 60px to become in view), then move it down 60px // to be because we need to move it down 60px to become in view), then move it down 60px
if (Math.abs($matchingElement.offset().top - $(window).scrollTop()) < 20) { if (Math.abs($matchingElement.offset().top - $(window).scrollTop()) < 20) {

View File

@ -4,6 +4,8 @@
<?cs include:"head_tag.cs" ?> <?cs include:"head_tag.cs" ?>
<body class="gc-documentation <?cs if:(reference.gms || reference.gcm) ?>google<?cs /if ?> <body class="gc-documentation <?cs if:(reference.gms || reference.gcm) ?>google<?cs /if ?>
<?cs if:(guide||develop||training||reference||tools||sdk) ?>develop<?cs <?cs if:(guide||develop||training||reference||tools||sdk) ?>develop<?cs
if:reference ?> reference<?cs
/if ?><?cs
elif:design ?>design<?cs elif:design ?>design<?cs
elif:distribute ?>distribute<?cs elif:distribute ?>distribute<?cs
/if ?>" itemscope itemtype="http://schema.org/Article"> /if ?>" itemscope itemtype="http://schema.org/Article">

View File

@ -4,6 +4,8 @@
<?cs include:"head_tag.cs" ?> <?cs include:"head_tag.cs" ?>
<body class="gc-documentation <?cs if:(reference.gms || reference.gcm) ?>google<?cs /if ?> <body class="gc-documentation <?cs if:(reference.gms || reference.gcm) ?>google<?cs /if ?>
<?cs if:(guide||develop||training||reference||tools||sdk) ?>develop<?cs <?cs if:(guide||develop||training||reference||tools||sdk) ?>develop<?cs
if:reference ?> reference<?cs
/if ?><?cs
elif:design ?>design<?cs elif:design ?>design<?cs
elif:distribute ?>distribute<?cs elif:distribute ?>distribute<?cs
/if ?>" itemscope itemtype="http://schema.org/Article"> /if ?>" itemscope itemtype="http://schema.org/Article">

View File

@ -5,6 +5,8 @@
<body class="gc-documentation <?cs if:(reference.gms || reference.gcm) ?>google<?cs /if ?> <body class="gc-documentation <?cs if:(reference.gms || reference.gcm) ?>google<?cs /if ?>
<?cs if:(guide||develop||training||reference||tools||sdk) ?>develop<?cs <?cs if:(guide||develop||training||reference||tools||sdk) ?>develop<?cs
if:reference ?> reference<?cs
/if ?><?cs
elif:design ?>design<?cs elif:design ?>design<?cs
elif:distribute ?>distribute<?cs elif:distribute ?>distribute<?cs
/if ?>"> /if ?>">

View File

@ -4,6 +4,8 @@
<?cs include:"head_tag.cs" ?> <?cs include:"head_tag.cs" ?>
<body class="gc-documentation <?cs if:(reference.gms || reference.gcm) ?>google<?cs /if ?> <body class="gc-documentation <?cs if:(reference.gms || reference.gcm) ?>google<?cs /if ?>
<?cs if:(guide||develop||training||reference||tools||sdk) ?>develop<?cs <?cs if:(guide||develop||training||reference||tools||sdk) ?>develop<?cs
if:reference ?> reference<?cs
/if ?><?cs
elif:design ?>design<?cs elif:design ?>design<?cs
elif:distribute ?>distribute<?cs elif:distribute ?>distribute<?cs
/if ?>"> /if ?>">