Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Setup Header
- **/
- setupHeader() {
- var scrollOffset = parseInt($('#header').outerHeight());
- // if one-page menu items click
- $('a[href*="#!/"]').click(function () {
- var $link = $(this),
- url = $link.attr('href');
- // is one page link
- if (url.indexOf('#!/') !== -1) {
- var linkParts = url.split('#!/'),
- sectionID = linkParts[1],
- $section = $('#' + sectionID);
- if ($section.length) {
- $('html, body').animate({
- scrollTop: parseInt($section.offset().top - scrollOffset)
- }, 800, function () {
- // Add hash (#) to URL when done scrolling (default click behavior)
- window.location.hash = '#!/' + sectionID;
- });
- return false;
- }
- }
- });
- var hash = window.location.hash;
- // if page URL contains one-page hash
- if (hash.indexOf('#!/') !== -1) {
- var linkParts = hash.split('#!/'),
- sectionID = linkParts[1],
- $section = $('#' + sectionID);
- if ($section.length) {
- setTimeout(function () {
- $('html, body').animate({
- scrollTop: parseInt($section.offset().top - scrollOffset)
- }, 800, function () {
- $('#header_menu li').removeClass('current-menu-item');
- $('#header_menu a').each(function () {
- if ($(this).attr('href').indexOf(hash) !== -1) {
- $(this).parent().addClass('current-menu-item');
- }
- });
- // Add hash (#) to URL when done scrolling (default click behavior)
- window.location.hash = '#!/' + sectionID;
- });
- }, 1000);
- return false;
- }
- }
- }
Add Comment
Please, Sign In to add comment