link target with absolute path on same page scrolls
This commit is contained in:
parent
50312db5f8
commit
f1a77d65c4
1 changed files with 19 additions and 7 deletions
|
@ -104,21 +104,33 @@
|
|||
});
|
||||
$('.url').click(function(event) {
|
||||
event.preventDefault();
|
||||
var href = $(this).attr('href');
|
||||
var $this = $(this);
|
||||
var href = $this.attr('href');
|
||||
$('.navbar-collapse').removeClass('in');
|
||||
$('.navbar-collapse').addClass('collapsing');
|
||||
if (href[0] === "#") {
|
||||
if ($(href).length) {
|
||||
$('html, body').animate({
|
||||
scrollTop: $(href).offset().top - 50
|
||||
}, 1000);
|
||||
}
|
||||
scrollToElement(href);
|
||||
} else if (href) {
|
||||
var path = $(this).prop('href').split('#');
|
||||
var currentPath = window.location.origin + window.location.pathname;
|
||||
if (!path[1]) {
|
||||
window.location = href;
|
||||
} else if (currentPath == path[0]) {
|
||||
scrollToElement('#' + path[1]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function scrollToElement(el) {
|
||||
var $el = $(el);
|
||||
if ($el.length) {
|
||||
$('html, body').animate({
|
||||
scrollTop: $el.offset().top - 50
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function verifiedUrl() {
|
||||
if (window.location.href.indexOf('#success') > -1) {
|
||||
form_success();
|
||||
|
|
Loading…
Reference in a new issue