Skip to content

Commit

Permalink
Merge pull request #1060 from jpetto/bug-890061-tweak-adaptive-nav-click
Browse files Browse the repository at this point in the history
Update scroll pos when clicking adaptive nav link. Bug 890061.
  • Loading branch information
alexgibson committed Jul 12, 2013
2 parents b07a86f + f8a8f5f commit a6f0571
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion media/css/firefox/os/firefox-os.less
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ section p, header p {

#adaptive-app-search {
position: absolute;
top: 200px;
top: 0;
left: 0;
width: 100%;
}
Expand Down
14 changes: 13 additions & 1 deletion media/js/firefox/os/desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
var nav_height = $masthead.height();

// adaptive scroll
var adaptive_text_offset = 200;
var scene_hooks_top = 620;
var $soccer_hook = $('#soccer-hook');
var $cafe_hook = $('#cafe-hook');
Expand Down Expand Up @@ -395,7 +396,15 @@
// GA track click
navClickGATrack(this.hash);

var new_scroll = $($(this).attr('href')).offset().top;
var href = $(this).attr('href');
var new_scroll = $(href).offset().top;

// special case for adaptive section
// text is offset for scrolling, so we want to jump a bit
// further than the actual anchor
if (href == '#adaptive-wrapper') {
new_scroll += adaptive_text_offset;
}

$w.scrollTop(new_scroll - nav_height);
});
Expand Down Expand Up @@ -456,6 +465,9 @@
// add scroller-on class for css repositioning, & set total height
$('#adaptive-wrapper').addClass('scroller-on').css('height', pinDur + 'px');

// add offset to initial adaptive text (so user doesn't scroll by too fast)
$('#adaptive-app-search').css('top', adaptive_text_offset + 'px');

// set height of blue mask covering bottom of adaptive content
$adaptive_mask.css('height', 620);

Expand Down

0 comments on commit a6f0571

Please sign in to comment.