use requestAnimationFrame rather than interval

This commit is contained in:
Marty Alcala 2016-11-11 17:24:01 -05:00
commit c7700eec0d

View file

@ -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) {