diff --git a/bower.json b/bower.json index 9000c2c..00aaa17 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-scroll-glue", - "version": "2.0.6", + "version": "2.0.7", "homepage": "https://github.com/Luegg/angularjs-scroll-glue", "authors": [ "Lukas Wegmann" diff --git a/package.json b/package.json index 3ff2e13..d941e54 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Lukas Wegmann", "name": "angularjs-scroll-glue", - "version": "2.0.6", + "version": "2.0.7", "main" : "src/scrollglue.js", "keywords": [ "angular", diff --git a/src/scrollglue.js b/src/scrollglue.js index 04c3649..b5c8a33 100644 --- a/src/scrollglue.js +++ b/src/scrollglue.js @@ -64,11 +64,13 @@ link: function(scope, $el, attrs){ var el = $el[0], activationState = createActivationState($parse, attrs[attrName], scope); - + function scrollIfGlued() { - if(activationState.getValue() && !direction.isAttached(el)){ - direction.scroll(el); - } + $timeout(function(){ + if(activationState.getValue() && !direction.isAttached(el) ){ + direction.scroll(el); + } + },0,false); } function onScroll() { @@ -77,12 +79,13 @@ scope.$watch(scrollIfGlued); - $timeout(scrollIfGlued, 0, false); + scrollIfGlued(); $window.addEventListener('resize', scrollIfGlued, false); - $el.bind('scroll', onScroll); - + $el.on('scroll', function(){ + $timeout(onScroll, 0, false); + }); // Remove listeners on directive destroy $el.on('$destroy', function() {