Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Using the "transition", to animate scrolling. #1543

Closed
4 changes: 3 additions & 1 deletion js/angular/directive/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ function($timeout, $controller, $ionicBind, $ionicConfig) {
scrollbarY: '@',
startX: '@',
startY: '@',
scrollEventInterval: '@'
scrollEventInterval: '@',
hasTransition: '@'
});
$scope.direction = $scope.direction || 'y';

Expand All @@ -118,6 +119,7 @@ function($timeout, $controller, $ionicBind, $ionicConfig) {
delegateHandle: attr.delegateHandle,
locking: (attr.locking || 'true') === 'true',
bouncing: $scope.$eval($scope.hasBouncing),
transition: $scope.$eval($scope.hasTransition) || 0,
startX: $scope.$eval($scope.startX) || 0,
startY: $scope.$eval($scope.startY) || 0,
scrollbarX: $scope.$eval($scope.scrollbarX) !== false,
Expand Down
4 changes: 3 additions & 1 deletion js/angular/directive/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ function($timeout, $controller, $ionicBind) {
scrollbarY: '@',
zooming: '@',
minZoom: '@',
maxZoom: '@'
maxZoom: '@',
hasTransition: '@'
});
$scope.direction = $scope.direction || 'y';

Expand All @@ -92,6 +93,7 @@ function($timeout, $controller, $ionicBind) {
locking: ($attr.locking || 'true') === 'true',
bouncing: $scope.$eval($attr.hasBouncing),
paging: isPaging,
transition: $scope.$eval($scope.hasTransition) || false,
scrollbarX: $scope.$eval($scope.scrollbarX) !== false,
scrollbarY: $scope.$eval($scope.scrollbarY) !== false,
scrollingX: $scope.direction.indexOf('x') >= 0,
Expand Down
15 changes: 13 additions & 2 deletions js/angular/service/collectionRepeatManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ function($rootScope, $timeout) {
this.setCurrentIndex(0);

//Override scrollview's render callback
this.scrollView.__$callback = this.scrollView.__callback;
this.scrollView.__callback = angular.bind(this, this.renderScroll);
if(this.scrollView.options.transition){
this.scrollView.__onScrollTransition = angular.bind(this, this.renderScrollTransition);
}else{
this.scrollView.__$callback = this.scrollView.__callback;
this.scrollView.__callback = angular.bind(this, this.renderScroll);
}

function getViewportSize() { return self.viewportSize; }
//Set getters and setters to match whether this scrollview is vertical or not
Expand Down Expand Up @@ -192,6 +196,13 @@ function($rootScope, $timeout) {
return this.scrollView.__$callback(transformLeft, transformTop, zoom, wasResize);
}),

renderScrollTransition: function(transformLeft, transformTop){
if (this.isVertical) {
this.renderIfNeeded(transformTop);
} else {
this.renderIfNeeded(transformLeft);
}
},
renderIfNeeded: function(scrollPos) {
if ((this.hasNextIndex && scrollPos >= this.nextPos) ||
(this.hasPrevIndex && scrollPos < this.previousPos)) {
Expand Down
Loading