From e6d2d2f91452b5310499cab631d25777d7f1ac58 Mon Sep 17 00:00:00 2001 From: Edward Opare-Aryee Date: Fri, 10 Jun 2016 10:00:18 +0100 Subject: [PATCH] Release v0.1.0 --- bower.json | 2 +- dist/angular-smart-nav.js | 31 ++++++++++++++++++++++++++++++- dist/angular-smart-nav.min.js | 6 ++++-- package.json | 2 +- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index a2fda0b..0bf1a1e 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "angular-smart-nav", "description": "Show or hide a navbar when scrolling in any particular direction and or minimise nav when scrolling pass the navbar", - "version": "0.0.2", + "version": "0.1.0", "homepage": "https://github.com/thisissoon/angular-smart-nav", "license": "MIT", "ignore": [ diff --git a/dist/angular-smart-nav.js b/dist/angular-smart-nav.js index cc1b92d..1e23774 100644 --- a/dist/angular-smart-nav.js +++ b/dist/angular-smart-nav.js @@ -1,4 +1,4 @@ -/*! angular-smart-nav - v0.0.2 - 2015-11-03 */ +/*! angular-smart-nav - v0.1.0 - 2016-06-10 */ 'use strict'; /** * Module that detects the last scroll direction and @@ -14,6 +14,10 @@ * `scrolling-up`. If the user has scrolled beyond the * height of the nav the class `minimised-mode`. * + * If the element is at the top of the viewport or above + * it then the class `affix` will be added. This is useful + * for making an element sticky when user has scrolled to it + * * @module sn.smartNav * @main sn.smartNav * @author SOON_ @@ -98,6 +102,20 @@ angular.module('sn.smartNav', [ $element.removeClass('minimised-mode'); } }; + /** + * Calulate if the element is at top or above viewport + * so we can 'affix' it to top of the viewport. + * @private + * @method calAffixedMode + */ + var calAffixedMode = function calAffixedMode(){ + var positionFromTop = $element[0].getBoundingClientRect().top; + if (positionFromTop <= 0 ) { + $element.addClass('affix'); + } else { + $element.removeClass('affix'); + } + }; /** * window `scroll` event handler. * Gets the current scroll postion and calulates @@ -112,12 +130,23 @@ angular.module('sn.smartNav', [ calScrollDir(scrollTop); calMinimisedMode(scrollTop); + calAffixedMode(); lastScrollTop = scrollTop; }; + /** + * Clear event listeners + * @method onDestroy + */ + var onDestroy = function onDestroy(){ + angular.element($window).off('scroll', onScroll); + }; + $scope.$on('$destroy', onDestroy); angular.element($window).on('scroll', onScroll); } }; } ]); + +//# sourceMappingURL=angular-smart-nav.js.map \ No newline at end of file diff --git a/dist/angular-smart-nav.min.js b/dist/angular-smart-nav.min.js index c45bf79..850e530 100644 --- a/dist/angular-smart-nav.min.js +++ b/dist/angular-smart-nav.min.js @@ -1,2 +1,4 @@ -/*! angular-smart-nav - v0.0.2 - 2015-11-03 */ -!function(a){"use strict";angular.module("sn.smartNav",[]).directive("snSmartNav",["$window","$document",function(a,b){return{restrict:"A",scope:{},link:function(c,d){var e=0,f=!1,g=function(a){return a>e},h=function(a){return e>a},i=function(a){f&&h(a)?(f=!1,d.removeClass("scrolling-down"),d.addClass("scrolling-up")):!f&&g(a)&&(f=!0,d.removeClass("scrolling-up"),d.addClass("scrolling-down"))},j=function(a){a>d[0].offsetHeight?d.addClass("minimised-mode"):d.removeClass("minimised-mode")},k=function(){var a=b[0].documentElement,c=b[0].body,d=a&&a.scrollTop||c&&c.scrollTop||0;i(d),j(d),e=d};angular.element(a).on("scroll",k)}}}])}(window); \ No newline at end of file +/*! angular-smart-nav - v0.1.0 - 2016-06-10 */ + +!function(a){"use strict";angular.module("sn.smartNav",[]).directive("snSmartNav",["$window","$document",function(a,b){return{restrict:"A",scope:{},link:function(c,d){var e=0,f=!1,g=function(a){return a>e},h=function(a){return e>a},i=function(a){f&&h(a)?(f=!1,d.removeClass("scrolling-down"),d.addClass("scrolling-up")):!f&&g(a)&&(f=!0,d.removeClass("scrolling-up"),d.addClass("scrolling-down"))},j=function(a){a>d[0].offsetHeight?d.addClass("minimised-mode"):d.removeClass("minimised-mode")},k=function(){var a=d[0].getBoundingClientRect().top;0>=a?d.addClass("affix"):d.removeClass("affix")},l=function(){var a=b[0].documentElement,c=b[0].body,d=a&&a.scrollTop||c&&c.scrollTop||0;i(d),j(d),k(),e=d},m=function(){angular.element(a).off("scroll",l)};c.$on("$destroy",m),angular.element(a).on("scroll",l)}}}])}(window); +//# sourceMappingURL=angular-smart-nav.min.js.map \ No newline at end of file diff --git a/package.json b/package.json index d102492..3de167c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-smart-nav", "private": false, - "version": "0.0.2", + "version": "0.1.0", "description": "Show or hide a navbar when scrolling in any particular direction and or minimise nav when scrolling pass the navbar", "repository": "https://github.com/thisissoon/angular-smart-nav", "license": "MIT",