From c7700eec0d2827756caaae254ebe8bc52d203cf8 Mon Sep 17 00:00:00 2001 From: Marty Alcala Date: Fri, 11 Nov 2016 17:24:01 -0500 Subject: [PATCH] use requestAnimationFrame rather than interval --- src/js/controllers/walletDetails.js | 34 +++++++++++++---------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/js/controllers/walletDetails.js b/src/js/controllers/walletDetails.js index d10a0767f..b6fcb6849 100644 --- a/src/js/controllers/walletDetails.js +++ b/src/js/controllers/walletDetails.js @@ -241,9 +241,12 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun $scope.amountScale = 'scale3d(' + 1 + ',' + 1 + ',' + 1+ ')'; var prevPos; - $scope.getScrollPosition = function(){ + function getScrollPosition(){ var pos = $ionicScrollDelegate.getScrollPosition().top; if(pos === prevPos) { + $window.requestAnimationFrame(function() { + getScrollPosition(); + }); return; } prevPos = pos; @@ -267,30 +270,23 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun var s = amountScale; $scope.altAmountOpacity = (amountHeight - 100)/80; - - //$window.requestAnimationFrame(function() { + $window.requestAnimationFrame(function() { $scope.amountHeight = amountHeight + 'px'; $scope.contentMargin = contentMargin + 'px'; $scope.amountScale = 'scale3d(' + s + ',' + s + ',' + s+ ')'; - //$scope.$evalAsync(angular.noop); - //}); - }; - - // $scope.getScrollPosition(); - - // $timeout(function() { - // - // }, 300); + $scope.$digest(); + getScrollPosition(); + }); + } var scrollInterval; $scope.$on("$ionicView.enter", function(event, data) { - scrollInterval = $interval(function(){ - $scope.getScrollPosition(); - }, 10); + $timeout(function() { + getScrollPosition(); + }, 100); }); - $scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.walletId = data.stateParams.walletId; storageService.getBackupFlag($scope.walletId, function(err, flag) { @@ -318,9 +314,9 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun ]; }); - $scope.$on("$ionicView.beforeLeave", function(event, data) { - $interval.cancel(scrollInterval); - }); + // $scope.$on("$ionicView.beforeLeave", function(event, data) { + // $interval.cancel(scrollInterval); + // }); $scope.$on("$ionicView.leave", function(event, data) { lodash.each(listeners, function(x) {