Fixed infinity problem in scroll view

I guess you can't divide by zero still.
This commit is contained in:
Max Lynch
2013-10-30 11:14:24 -05:00
parent 83a00fa301
commit 979fe8fb7b
7 changed files with 1024 additions and 799 deletions

View File

@ -374,7 +374,7 @@ angular.module('ionic.ui.list', ['ngAnimate'])
.directive('listItem', function() {
return {
restrict: 'E',
require: '^list',
require: ['?^list', '?^virtualList'],
replace: true,
transclude: true,
scope: {
@ -409,6 +409,13 @@ angular.module('ionic.ui.list', ['ngAnimate'])
</div>\
</li>',*/
link: function($scope, $element, $attr, list) {
// Grab the parent list controller
if(list[0]) {
list = list[0];
} else if(list[1]) {
list = list[1];
}
$scope.isEditing = false;
$scope.deleteIcon = list.scope.deleteIcon;
$scope.reorderIcon = list.scope.reorderIcon;
@ -454,6 +461,53 @@ angular.module('ionic.ui.list', ['ngAnimate'])
return function($scope, $element, $attr) {
var lv = new ionic.views.List({el: $element[0]});
if(attr.animation) {
$element.addClass(attr.animation);
}
};
}
};
})
.directive('virtualList', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
scope: {
isEditing: '=',
deleteIcon: '@',
reorderIcon: '@',
itemHeight: '@'
},
// So we can require being under this
controller: function($scope) {
var _this = this;
this.scope = $scope;
$scope.$watch('isEditing', function(v) {
_this.isEditing = true;
});
},
template: '<div class="scroll"><ul class="list" ng-class="{\'list-editing\': isEditing}" ng-transclude>\
</ul></div>',
compile: function(element, attr, transclude) {
return function($scope, $element, $attr) {
var lv = new ionic.views.ListView({
el: $element[0],
listEl: $element[0].children[0],
isVirtual: true,
itemHeight: $scope.itemHeight,
renderViewport: function(high, low, start, end) {
console.log('RENDER VIEWPORT', high, low, start, end);
}
});
if(attr.animation) {
$element.addClass(attr.animation);
}