diff --git a/README.md b/README.md index 71f8689..a83d7bc 100644 --- a/README.md +++ b/README.md @@ -115,8 +115,13 @@ Copyright (C) 2014 Jozef Butko
[@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 @@ -127,6 +132,7 @@ Copyright (C) 2014 Jozef Butko
- 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
diff --git a/bower.json b/bower.json index 379d462..dc7b57b 100644 --- a/bower.json +++ b/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", diff --git a/jquery.stickyNavbar.js b/jquery.stickyNavbar.js index d723f3a..ba84d33 100644 --- a/jquery.stickyNavbar.js +++ b/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 * @@ -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 @@ -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 @@ -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 @@ -277,4 +291,4 @@ }); // return this.each end }; // $.fn.stickyNavbar end -})(jQuery, window, document); // document ready end +})(jQuery, window, document); // document ready end \ No newline at end of file diff --git a/jquery.stickyNavbar.min.js b/jquery.stickyNavbar.min.js index 9d8a1c9..10de34d 100644 --- a/jquery.stickyNavbar.min.js +++ b/jquery.stickyNavbar.min.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 * @@ -17,7 +17,7 @@ * * COPYRIGHT (C) 2014 Jozef Butko * https://github.com/jbutko - * LAST UPDATE: 23/07/2014 + * LAST UPDATE: 25/08/2014 * */ -!function(a,b,c){"use strict";a.fn.stickyNavbar=function(d){var e=a.extend({activeClass:"active",sectionSelector:"scrollto",animDuration:350,startAt:0,easing:"swing",animateCSS:!0,animateCSSRepeat:!1,cssAnimation:"fadeInDown",jqueryEffects:!1,jqueryAnim:"slideDown",selector:"a",mobile:!1,mobileWidth:480,zindex:9999,stickyModeClass:"sticky",unstickyModeClass:"unsticky"},d),f=a("."+e.sectionSelector);return this.each(function(){var d=a(this),g=d.css("position"),h=d.css("zIndex"),i=d.offset().top,j="auto"===d.css("top")?0:d.css("top"),k="a"===e.selector?d.find("li a"):d.find("li"),m=(d.find("li a[href*=#]"),d.outerHeight(!0)),n=0;k.click(function(b){var c=k.index(this),f=a(this).attr("href");++n,"0"===c&&(n=0),b.preventDefault(),1===n&&d.offset().top>i?a("html, body").stop().animate({scrollTop:a(f).offset().top-m+2+"px"},{duration:e.animDuration,easing:e.easing}):1===n||d.offset().top===i||0===c?a("html, body").stop().animate({scrollTop:a(f).offset().top-2*m+2+"px"},{duration:e.animDuration,easing:e.easing}):2===n&&d.offset().top=b&&c>=n&&("a"===e.selector?d.find('li a[href~="#'+this.id+'"]').addClass(e.activeClass):d.find('li a[href~="#'+this.id+'"]').parent().addClass(e.activeClass))}),n>=i+e.startAt?(d.removeClass(e.unstickyModeClass).addClass(" "+e.stickyModeClass),d.css({position:"fixed",zIndex:e.zindex}).stop(),e.jqueryEffects?(e.animateCSSRepeat||d.hide().stop()[e.jqueryAnim](e.animDuration,e.easing),d.hide().stop()[e.jqueryAnim](e.animDuration,e.easing)):e.animateCSS?e.animateCSSRepeat?d.addClass(e.cssAnimation+" animated").one("animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd",function(){d.removeClass(e.cssAnimation+" animated")}):d.addClass(e.cssAnimation+" animated").one("animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd"):d.stop()):d.css({position:e.$selfPosition,zIndex:h}).removeClass(e.stickyModeClass).addClass(" "+e.unstickyModeClass),l.scrollTop()+p>=a(c).height()&&k.removeClass(e.activeClass).last().addClass(e.activeClass),i>=n&&(d.removeClass(e.cssAnimation+" animated"),e.jqueryEffects?(0===n&&k.removeClass(e.activeClass),n>=i?d.css({position:"fixed",zIndex:e.zindex}).hide().stop()[e.jqueryAnim](e.animDuration,e.easing):d.css({position:g,zIndex:e.zindex})):(0===n&&k.removeClass(e.activeClass),d.css({position:g,top:j}).stop().animate({top:j},e.animDuration,e.easing))),void 0)};a(b).scroll(o),a(b).ready(o),a(b).resize(o)})}}(jQuery,window,document); \ No newline at end of file +!function(a,b,c){"use strict";a.fn.stickyNavbar=function(d){var e=a.extend({activeClass:"active",sectionSelector:"scrollto",animDuration:350,startAt:0,easing:"swing",animateCSS:!0,animateCSSRepeat:!1,cssAnimation:"fadeInDown",jqueryEffects:!1,jqueryAnim:"slideDown",selector:"a",mobile:!1,mobileWidth:480,zindex:9999,stickyModeClass:"sticky",unstickyModeClass:"unsticky"},d),f=a("."+e.sectionSelector);return this.each(function(){var d=a(this),g=d.css("position"),h=d.css("zIndex"),i=d.offset().top,j="auto"===d.css("top")?0:d.css("top"),k="a"===e.selector?d.find("li a"):d.find("li"),m=(d.find("li a[href*=#]"),d.outerHeight(!0)),n=0;k.click(function(b){var c=a(this).attr("href");if("http"===c.substring(0,4)||"mailto:"===c.substring(0,7))return!0;var f=k.index(this),g=c;++n,"0"===f&&(n=0),b.preventDefault(),1===n&&d.offset().top>i?a("html, body").stop().animate({scrollTop:a(g).offset().top-m+2+"px"},{duration:e.animDuration,easing:e.easing}):1===n||d.offset().top===i||0===f?a("html, body").stop().animate({scrollTop:a(g).offset().top-2*m+2+"px"},{duration:e.animDuration,easing:e.easing}):2===n&&d.offset().top=b&&c>=n&&("a"===e.selector?d.find('li a[href~="#'+this.id+'"]').addClass(e.activeClass):d.find('li a[href~="#'+this.id+'"]').parent().addClass(e.activeClass))}),n>=i+e.startAt?(d.removeClass(e.unstickyModeClass).addClass(" "+e.stickyModeClass),d.css({position:"fixed",zIndex:e.zindex}).stop(),e.jqueryEffects?(e.animateCSSRepeat||d.hide().stop()[e.jqueryAnim](e.animDuration,e.easing),d.hide().stop()[e.jqueryAnim](e.animDuration,e.easing)):e.animateCSS?e.animateCSSRepeat?d.addClass(e.cssAnimation+" animated").one("animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd",function(){d.removeClass(e.cssAnimation+" animated")}):d.addClass(e.cssAnimation+" animated").one("animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd"):d.stop()):d.css({position:e.$selfPosition,zIndex:h}).removeClass(e.stickyModeClass).addClass(" "+e.unstickyModeClass),l.scrollTop()+p>=a(c).height()&&k.removeClass(e.activeClass).last().addClass(e.activeClass),i>=n&&(d.removeClass(e.cssAnimation+" animated"),e.jqueryEffects?(0===n&&k.removeClass(e.activeClass),n>=i?d.css({position:"fixed",zIndex:e.zindex}).hide().stop()[e.jqueryAnim](e.animDuration,e.easing):d.css({position:g,zIndex:e.zindex})):(0===n&&k.removeClass(e.activeClass),d.css({position:g,top:j}).stop().animate({top:j},e.animDuration,e.easing))),void 0)};a(b).scroll(o),a(b).ready(o),a(b).resize(o)})}}(jQuery,window,document); \ No newline at end of file diff --git a/stickyNavbar.js.jquery.json b/stickyNavbar.js.jquery.json index d8615ee..167bff4 100644 --- a/stickyNavbar.js.jquery.json +++ b/stickyNavbar.js.jquery.json @@ -9,7 +9,7 @@ "navigation", "sticky" ], - "version": "1.1.1", + "version": "1.1.2", "author": { "name": "Jozef Butko", "email": "jbutko@gmail.com",