am b16376f2
: Change scroll position with javascript instead of CSS. Makes scroll adjustment work for all types of anchors. bug: 15129373
* commit 'b16376f2e600008c0d7233a919edf02a30237a9a': Change scroll position with javascript instead of CSS. Makes scroll adjustment work for all types of anchors. bug: 15129373
This commit is contained in:
commit
e8a3139ebf
2 changed files with 33 additions and 20 deletions
|
@ -5139,8 +5139,6 @@ a.download-sdk {
|
|||
margin-bottom: 0px;
|
||||
font-size: 20px;
|
||||
color: #363636;
|
||||
padding-top: 70px;
|
||||
margin-top:-60px;
|
||||
}
|
||||
.headerLine hr {
|
||||
overflow: hidden;
|
||||
|
@ -6388,11 +6386,3 @@ div.jd-descr > .resource-widget[data-section=distribute\/tools]
|
|||
.section-card-menu .card-info ul li {
|
||||
border-top-color: #7e3794 !important;
|
||||
}
|
||||
|
||||
div.jd-descr > h2:before, h3:before {
|
||||
display:block;
|
||||
content: " ";
|
||||
margin-top:-60px;
|
||||
height: 70px;
|
||||
visibility:hidden;
|
||||
}
|
|
@ -986,7 +986,10 @@ $(window).scroll(function(event) {
|
|||
$cardInfo.css({position: 'absolute', bottom:'0px', left:'0px', right:'0px', overflow:'visible'});
|
||||
});
|
||||
|
||||
resizeNav(); // must resize once loading is finished
|
||||
// Resize once loading is finished
|
||||
resizeNav();
|
||||
// Check if there's an anchor that we need to scroll into view
|
||||
offsetScrollForSticky();
|
||||
});
|
||||
|
||||
})();
|
||||
|
@ -1821,13 +1824,12 @@ function search_changed(e, kd, toroot)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
// Stop here if Google results are showing
|
||||
// If Google results are showing, return true to allow ajax search to execute
|
||||
else if ($("#searchResults").is(":visible")) {
|
||||
//If search_results is scrolled out of view, scroll to top on input
|
||||
// Also, if search_results is scrolled out of view, scroll to top to make results visible
|
||||
if ((sticky ) && (search.value != "")) {
|
||||
$('body,html').animate({scrollTop:0}, '500', 'swing');
|
||||
}
|
||||
// if results aren't showing (and text not empty), return true to allow search to execute
|
||||
return true;
|
||||
}
|
||||
// 38 UP ARROW
|
||||
|
@ -2497,6 +2499,25 @@ google.setOnLoadCallback(function(){
|
|||
}
|
||||
}, true);
|
||||
|
||||
/* Adjust the scroll position to account for sticky header, only if the hash matches an id */
|
||||
function offsetScrollForSticky() {
|
||||
var hash = location.hash;
|
||||
var $matchingElement = $(hash);
|
||||
// If there's no element with the hash as an ID, then look for an <a name=''> with it.
|
||||
if ($matchingElement.length < 1) {
|
||||
$matchingElement = $('a[name="' + hash.substr(1) + '"]');
|
||||
}
|
||||
// Sanity check that hash is a real hash and that there's an element with that ID on the page
|
||||
if ((hash.indexOf("#") == 0) && $matchingElement.length) {
|
||||
// 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
|
||||
if (Math.abs($matchingElement.offset().top - $(window).scrollTop()) < 20) {
|
||||
$(window).scrollTop($(window).scrollTop() - 60);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// when an event on the browser history occurs (back, forward, load) requery hash and do search
|
||||
$(window).hashchange( function(){
|
||||
// If the hash isn't a search query or there's an error in the query,
|
||||
|
@ -2506,6 +2527,7 @@ $(window).hashchange( function(){
|
|||
if (!$("#searchResults").is(":hidden")) {
|
||||
hideResults();
|
||||
}
|
||||
offsetScrollForSticky();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3516,6 +3538,7 @@ function showSamples() {
|
|||
while (i < resources.length) {
|
||||
var cardSize = cardSizes[j++ % cardSizes.length];
|
||||
cardSize = cardSize.replace(/^\s+|\s+$/,'');
|
||||
// console.log("cardsize is " + cardSize);
|
||||
// Some card sizes do not get a plusone button, such as where space is constrained
|
||||
// or for cards commonly embedded in docs (to improve overall page speed).
|
||||
plusone = !((cardSize == "6x2") || (cardSize == "6x3") ||
|
||||
|
|
Loading…
Reference in a new issue