Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation Enhancements with ID's and URL hashes #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ jQuery(document).ready(function ($) {
});

function goToByScroll(dataslide) {
//target the data-slide attr first
var $target = $('.slide[data-slide="' + dataslide + '"]'),
hash = $target.attr('id');
//if no data-slide attr is found with given name, look for id with dataslide value
if (!$target.length) {$target = $('.slide#' + dataslide); hash = dataslide;}

htmlbody.animate({
scrollTop: $('.slide[data-slide="' + dataslide + '"]').offset().top
}, 2000, 'easeInOutQuint');
scrollTop: $target.offset().top
}, 2000, 'easeInOutQuint',
//set the URL hash to match the ID of the slide
function(){location.hash = hash;});
}


Expand All @@ -52,4 +60,4 @@ jQuery(document).ready(function ($) {
});


});
});