From 9e86f9bb2bcb398b3d67ae4c6644a3f510b05d08 Mon Sep 17 00:00:00 2001 From: Joel Arvidsson Date: Tue, 11 Mar 2014 23:11:36 +0100 Subject: [PATCH] Released version 0.2.7. --- angular-scroll.js | 15 +++++++++++---- angular-scroll.min.js | 2 +- angular-scroll.min.js.map | 2 +- bower.json | 2 +- package.json | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/angular-scroll.js b/angular-scroll.js index 9c2f3ce..647a248 100644 --- a/angular-scroll.js +++ b/angular-scroll.js @@ -203,8 +203,14 @@ directive('duScrollspy', function($rootScope, scrollPosition) { toBeActive = toBeActive.spy; } if(currentlyActive === toBeActive) return; - if(currentlyActive) currentlyActive.$element.removeClass('active'); - if(toBeActive) toBeActive.$element.addClass('active'); + if(currentlyActive) { + currentlyActive.$element.removeClass('active'); + $rootScope.$broadcast('duScrollspy:becameInactive', currentlyActive.$element); + } + if(toBeActive) { + toBeActive.$element.addClass('active'); + $rootScope.$broadcast('duScrollspy:becameActive', toBeActive.$element); + } currentlyActive = toBeActive; } @@ -228,8 +234,9 @@ directive('duScrollspy', function($rootScope, scrollPosition) { return { link: function ($scope, $element, $attr) { - if (!$attr.href || $attr.href.indexOf('#') === -1) return; - var targetId = $attr.href.replace(/.*(?=#[^\s]+$)/, '').substring(1); + var href = $attr.ngHref || $attr.href; + if (!href || href.indexOf('#') === -1) return; + var targetId = href.replace(/.*(?=#[^\s]+$)/, '').substring(1); if(!targetId) return; var spy = new Spy(targetId, $element, -($attr.offset ? parseInt($attr.offset, 10) : 0)); diff --git a/angular-scroll.min.js b/angular-scroll.min.js index e95d10e..62a8fe2 100644 --- a/angular-scroll.min.js +++ b/angular-scroll.min.js @@ -1,2 +1,2 @@ -angular.module("duScroll",["duScroll.scroller","duScroll.scrollPosition","duScroll.scrollspy","duScroll.requestAnimation","duScroll.smoothScroll"]).value("duScrollDuration",1e3),angular.module("duScroll.requestAnimation",[]).factory("requestAnimation",["$window","$timeout",function(a,b){return a.requestAnimationFrame||a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame||a.msRequestAnimationFrame||function(a){b(a,1e3/60)}}]),angular.module("duScroll.scrollPosition",["duScroll.requestAnimation"]).factory("scrollPosition",["$document","$window","$rootScope","requestAnimation",function(a,b,c,d){var e=[],f=0,g=0,h=function(){c.$emit("$duScrollChanged",g),g=f;for(var a=0;aj&&b(l)};l()}}function f(a,b,d){e(c.x()+(a||0),c.y()+(b||0),d)}function g(a,b,c){if(angular.isElement(a)&&(a=a[0]||a,a.getBoundingClientRect)){var d=a.getBoundingClientRect();f(0,d.top+(!b||isNaN(b)?0:-b),c)}}return{scrollTo:e,scrollToElement:g,scrollDelta:f}}]),angular.module("duScroll.smoothScroll",["duScroll.scroller"]).directive("duSmoothScroll",["scroller","duScrollDuration",function(a,b){return{link:function(c,d,e){var f=angular.element(d[0]);f.on("click",function(c){if(e.href&&-1!==e.href.indexOf("#")){var d=document.getElementById(e.href.replace(/.*(?=#[^\s]+$)/,"").substring(1));if(d&&d.getBoundingClientRect){c.stopPropagation&&c.stopPropagation(),c.preventDefault&&c.preventDefault();var f=-(e.offset?parseInt(e.offset,10):0),g=e.duration?parseInt(e.duration,10):b,h=d.getBoundingClientRect();a.scrollDelta(0,h.top+(isNaN(f)?0:f),g)}}})}}}]),angular.module("duScroll.scrollspy",["duScroll.scrollPosition"]).directive("duScrollspy",["$rootScope","scrollPosition",function(a){function b(){for(var a,b,c,d=0;dj&&b(l)};l()}}function f(a,b,d){e(c.x()+(a||0),c.y()+(b||0),d)}function g(a,b,c){if(angular.isElement(a)&&(a=a[0]||a,a.getBoundingClientRect)){var d=a.getBoundingClientRect();f(0,d.top+(!b||isNaN(b)?0:-b),c)}}return{scrollTo:e,scrollToElement:g,scrollDelta:f}}]),angular.module("duScroll.smoothScroll",["duScroll.scroller"]).directive("duSmoothScroll",["scroller","duScrollDuration",function(a,b){return{link:function(c,d,e){var f=angular.element(d[0]);f.on("click",function(c){if(e.href&&-1!==e.href.indexOf("#")){var d=document.getElementById(e.href.replace(/.*(?=#[^\s]+$)/,"").substring(1));if(d&&d.getBoundingClientRect){c.stopPropagation&&c.stopPropagation(),c.preventDefault&&c.preventDefault();var f=-(e.offset?parseInt(e.offset,10):0),g=e.duration?parseInt(e.duration,10):b,h=d.getBoundingClientRect();a.scrollDelta(0,h.top+(isNaN(f)?0:f),g)}}})}}}]),angular.module("duScroll.scrollspy",["duScroll.scrollPosition"]).directive("duScrollspy",["$rootScope","scrollPosition",function(a){function b(){for(var b,c,d,g=0;g