Skip to content

Commit

Permalink
v1.1.2: ignore external links and just let them open fix - pull request
Browse files Browse the repository at this point in the history
#15 by Globegitter
  • Loading branch information
jbutko committed Aug 25, 2014
1 parent d7a6316 commit 4b0c46e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 22 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -115,8 +115,13 @@ Copyright (C) 2014 Jozef Butko<br>
[@jozefbutko](http://www.twitter.com/jozefbutko)

##Changelog
###1.1.2
- ignore external links and just let them open fix - pull request #15 by Globegitter
25/07/2014

###1.1.1
- just a readme file update
23/07/2014

###1.1.0
- stickyMode/unstickyMode class added
Expand All @@ -127,6 +132,7 @@ Copyright (C) 2014 Jozef Butko<br>
- bottomAnimation option removed (unstable behaviour)
- navOffset option removed (unstable behaviour)
- credits for feature requests/points: @Phyxion, @oniric85, @coolboy4598
23/07/2014

###1.0.5
- animateCSSRepeat Fix<br>
Expand Down
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "stickyNavbar.js",
"version": "1.0.0",
"version": "1.1.1",
"homepage": "https://github.com/jbutko/stickyNavbar.js",
"author": {
"name": "Jozef Butko",
Expand Down
48 changes: 31 additions & 17 deletions jquery.stickyNavbar.js
@@ -1,5 +1,5 @@
/*
* stickyNavbar.js v1.1.1
* stickyNavbar.js v1.1.2
* https://github.com/jbutko/stickyNavbar.js
* Fancy sticky navigation jQuery plugin with smart anchor links highlighting
*
Expand All @@ -17,7 +17,7 @@
*
* COPYRIGHT (C) 2014 Jozef Butko
* https://github.com/jbutko
* LAST UPDATE: 23/07/2014
* LAST UPDATE: 25/08/2014
*
*/
/* The semi-colon before function invocation is a safety net against concatenated
Expand Down Expand Up @@ -69,11 +69,13 @@
var clicks = 0;

/* Smooth scrolling logic */
menuItems.click(function (e) {
var href = $(this).attr("href");
if (href.substring(0, 4) === 'http' || href.substring(0, 7) === 'mailto:') {
return true;
}
menuItems.click(function(e) {
/* v1.1.2: Ignore external links and just let them open - pull request #15 by Globegitter */
var href = $(this).attr("href");
if (href.substring(0, 4) === 'http' || href.substring(0, 7) === 'mailto:') {
return true;
}

/* Get index of clicked nav link */
var index = menuItems.index(this),
section = href; // Get href attr of clicked nav link
Expand All @@ -96,30 +98,42 @@

$("html, body").stop().animate({
scrollTop: $(section).offset().top - thisHeight + 2 + 'px'
}, {duration: options.animDuration, easing: options.easing});
}, {
duration: options.animDuration,
easing: options.easing
});

/* v1.0.3: Overlapping fix */
/* If it is first click after page load or we are at the top of the page or user return back on home: Then add 'this' height 2 times to fix overlapping */
/* v1.0.3: Overlapping fix */
/* If it is first click after page load or we are at the top of the page or user return back on home: Then add 'this' height 2 times to fix overlapping */
} else if (clicks === 1 || $self.offset().top === $selfScrollTop || index === 0) {

$("html, body").stop().animate({
scrollTop: $(section).offset().top - 2 * thisHeight + 2 + 'px'
}, {duration: options.animDuration, easing: options.easing});
}, {
duration: options.animDuration,
easing: options.easing
});

/* v1.0.5: Inaccurate scrolling fix */
/* If it is second click and we are scrolling upwards then add 'this' height just once */
/* v1.0.5: Inaccurate scrolling fix */
/* If it is second click and we are scrolling upwards then add 'this' height just once */
} else if (clicks === 2 && ($self.offset().top < $selfScrollTop)) {

$("html, body").stop().animate({
scrollTop: $(section).offset().top + 2 + 'px'
}, {duration: options.animDuration, easing: options.easing});
}, {
duration: options.animDuration,
easing: options.easing
});

/* Else add 'this' height just once */
/* Else add 'this' height just once */
} else {

$("html, body").stop().animate({
scrollTop: $(section).offset().top - thisHeight + 2 + 'px'
}, {duration: options.animDuration, easing: options.easing});
}, {
duration: options.animDuration,
easing: options.easing
});

} // Smooth scrolling logic End

Expand Down Expand Up @@ -277,4 +291,4 @@

}); // return this.each end
}; // $.fn.stickyNavbar end
})(jQuery, window, document); // document ready end
})(jQuery, window, document); // document ready end
6 changes: 3 additions & 3 deletions jquery.stickyNavbar.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion stickyNavbar.js.jquery.json
Expand Up @@ -9,7 +9,7 @@
"navigation",
"sticky"
],
"version": "1.1.1",
"version": "1.1.2",
"author": {
"name": "Jozef Butko",
"email": "jbutko@gmail.com",
Expand Down

0 comments on commit 4b0c46e

Please sign in to comment.