From a7d97ab7a28969278da3ff0059cd27d7aa6c266b Mon Sep 17 00:00:00 2001 From: qpitlove Date: Thu, 9 Apr 2015 21:09:21 +0900 Subject: [PATCH 1/6] replace from $scope.evalAsync to $timeout with option for only NanoScroller Update ( don't call $rootScope.apply ) - by using $timeout instead of $scope.evalAsync what prevent executing $digest twice for performance --- scrollable.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scrollable.js b/scrollable.js index e56c669..a2a6492 100644 --- a/scrollable.js +++ b/scrollable.js @@ -65,21 +65,21 @@ function listener(newHeight, oldHeight) { // If this is first run, create nanoScroller if (newHeight === oldHeight) { - // First run must be async - scope.$evalAsync(function () { + // First run must be async by using $timeout instead of $scope.eval for prevent excuting $digest twice + $timeout(function () { $nanoElement.nanoScroller(options); $nanoElement.nanoScroller(); - }); + }, 0, false); } //If scroller was on the bottom, scroll to bottom else if (newHeight !== oldHeight && contentElement.scrollTop && (oldHeight - contentElement.scrollTop - parentElement.clientHeight) < scrollableConfig.bottomMargin) { - scope.$evalAsync(function () { + $timeout(function () { // To make right calculation scroller must be reseted // See https://github.com/maxaon/angular-nanoscroller/issues/4 $nanoElement.nanoScroller(); $nanoElement.nanoScroller({scroll: 'bottom'}); - }); + }, 0, false); } // Otherwise just update the pane From 77be3b974777a00ed113dbe6acbd85718c47b935 Mon Sep 17 00:00:00 2001 From: qpitlove Date: Thu, 9 Apr 2015 21:09:39 +0900 Subject: [PATCH 2/6] replace from $scope.evalAsync to $timeout with option for only NanoScroller Update ( don't call $rootScope.apply ) - by using $timeout instead of $scope.evalAsync what prevent executing $digest twice for performance --- scrollable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scrollable.js b/scrollable.js index a2a6492..7f15662 100644 --- a/scrollable.js +++ b/scrollable.js @@ -65,7 +65,7 @@ function listener(newHeight, oldHeight) { // If this is first run, create nanoScroller if (newHeight === oldHeight) { - // First run must be async by using $timeout instead of $scope.eval for prevent excuting $digest twice + // First run must be async by using $timeout instead of $scope.evalAsync for prevent executing $digest twice $timeout(function () { $nanoElement.nanoScroller(options); $nanoElement.nanoScroller(); From 648cd42e06aec79022355f737ccf6b171cc9888f Mon Sep 17 00:00:00 2001 From: qpitlove Date: Thu, 9 Apr 2015 21:21:42 +0900 Subject: [PATCH 3/6] version up nano scroller, angular --- bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 0da4fdb..ab08b6f 100644 --- a/bower.json +++ b/bower.json @@ -22,7 +22,7 @@ "tests" ], "dependencies": { - "nanoscroller": "~0.8.0", - "angular": "~1.2" + "nanoscroller": "~0.8.5", + "angular": "~1.3" } } From 75f883e946fb0147f9544ef1a42ea39e1b64c125 Mon Sep 17 00:00:00 2001 From: qpitlove Date: Mon, 20 Apr 2015 19:53:02 +0900 Subject: [PATCH 4/6] =?UTF-8?q?nano-content=20element=20=EC=A1=B4=EC=9E=AC?= =?UTF-8?q?=ED=95=A0=20=EA=B2=BD=EC=9A=B0=EC=97=90=EB=A7=8C=20listener=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scrollable.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scrollable.js b/scrollable.js index 7f15662..4968de0 100644 --- a/scrollable.js +++ b/scrollable.js @@ -63,6 +63,8 @@ options = angular.extend({}, nanoScrollerDefaults, convertStringToValue(attr), scope.$eval(attr['scrollable'])); function listener(newHeight, oldHeight) { + if (!$nanoElement){ return; } + // If this is first run, create nanoScroller if (newHeight === oldHeight) { // First run must be async by using $timeout instead of $scope.evalAsync for prevent executing $digest twice From 35977d829fe8a5e10f90fd74d4a78b8287c266f2 Mon Sep 17 00:00:00 2001 From: qpitlove Date: Mon, 20 Apr 2015 20:04:30 +0900 Subject: [PATCH 5/6] =?UTF-8?q?$timeout=20timing=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=9D=BC=20listener=20=EC=8B=A4=ED=96=89=EC=8B=9C=EC=A0=90?= =?UTF-8?q?=EC=9D=B4=20=EC=95=84=EB=8B=8C=20=EC=8B=A4=EC=A0=9C=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=8F=99=EC=9E=91=20=EC=8B=9C=EC=A0=90=EC=97=90=20?= =?UTF-8?q?element=20=EC=B2=B4=ED=81=AC=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scrollable.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scrollable.js b/scrollable.js index 4968de0..db29204 100644 --- a/scrollable.js +++ b/scrollable.js @@ -63,14 +63,14 @@ options = angular.extend({}, nanoScrollerDefaults, convertStringToValue(attr), scope.$eval(attr['scrollable'])); function listener(newHeight, oldHeight) { - if (!$nanoElement){ return; } - // If this is first run, create nanoScroller if (newHeight === oldHeight) { // First run must be async by using $timeout instead of $scope.evalAsync for prevent executing $digest twice $timeout(function () { - $nanoElement.nanoScroller(options); - $nanoElement.nanoScroller(); + if ($nanoElement) { + $nanoElement.nanoScroller(options); + $nanoElement.nanoScroller(); + } }, 0, false); } //If scroller was on the bottom, scroll to bottom @@ -79,8 +79,10 @@ $timeout(function () { // To make right calculation scroller must be reseted // See https://github.com/maxaon/angular-nanoscroller/issues/4 - $nanoElement.nanoScroller(); - $nanoElement.nanoScroller({scroll: 'bottom'}); + if ($nanoElement) { + $nanoElement.nanoScroller(); + $nanoElement.nanoScroller({scroll: 'bottom'}); + } }, 0, false); } From 6cb3ccafa7d9d5bcfa01fc83d4f2593dfc2e3ebc Mon Sep 17 00:00:00 2001 From: qpitlove Date: Wed, 22 Apr 2015 18:54:11 +0900 Subject: [PATCH 6/6] =?UTF-8?q?FF=EC=97=90=EC=84=9C=20watch=EA=B0=92?= =?UTF-8?q?=EC=9D=B4=20=EC=84=A4=EC=A0=95=EB=90=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EC=9D=80=20=EA=B2=BD=EC=9A=B0=20=EC=9D=B5=EB=AA=85=20function?= =?UTF-8?q?=EC=9D=B4=20=EB=A6=AC=ED=84=B4=20=EB=90=98=EB=A9=B0=20exception?= =?UTF-8?q?=EC=9D=B4=20=EB=B0=9C=EC=83=9D=EB=90=98=EC=96=B4=20type=20strin?= =?UTF-8?q?g=20check=EB=A1=9C=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scrollable.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scrollable.js b/scrollable.js index db29204..913cf74 100644 --- a/scrollable.js +++ b/scrollable.js @@ -104,13 +104,17 @@ // Call scroller after transclusion listener(); } - else if (typeof attr['watch'] === 'string' || attr['watchCollection']) { - angular.forEach(splitter(attr['watch']), function (name) { - scope.$watch(name, collectionListener); - }); - angular.forEach(splitter(attr['watchCollection']), function (name) { - scope.$watchCollection(name, collectionListener); - }); + else if (attr['watch'] || attr['watchCollection']) { + if (typeof attr['watch'] === 'string' ){ + angular.forEach(splitter(attr['watch']), function (name) { + scope.$watch(name, collectionListener); + }); + } + if (typeof attr['watchCollection'] === 'string' ) { + angular.forEach(splitter(attr['watchCollection']), function (name) { + scope.$watchCollection(name, collectionListener); + }); + } } // If no watchers are supplied fall back to content element height check else {