Added support for offset start scroll view

This commit is contained in:
Max Lynch
2014-01-13 19:29:32 -06:00
parent db6ce5044f
commit 27311d5d18
8 changed files with 48 additions and 3 deletions

View File

@@ -1229,6 +1229,8 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
hasScrollY: '@',
scrollbarX: '@',
scrollbarY: '@',
startX: '@',
startY: '@',
scrollEventInterval: '@'
},
@@ -1274,6 +1276,8 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
sv = new ionic.views.Scroll({
el: $element[0],
bouncing: enableBouncing,
startX: $scope.$eval($scope.startX) || 0,
startY: $scope.$eval($scope.startY) || 0,
scrollbarX: $scope.$eval($scope.scrollbarX) !== false,
scrollbarY: $scope.$eval($scope.scrollbarY) !== false,
scrollingX: $scope.$eval($scope.hasScrollX) === true,

View File

File diff suppressed because one or more lines are too long

6
dist/js/ionic.js vendored
View File

@@ -2388,6 +2388,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
scrollingY: true,
scrollbarY: true,
startX: 0,
startY: 0,
/** The minimum size the scrollbars scale to while scrolling */
minScrollbarSizeX: 5,
minScrollbarSizeY: 5,
@@ -2467,6 +2470,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
});
};
this.__scrollLeft = this.options.startX;
this.__scrollTop = this.options.startY;
// Get the render update function, initialize event handlers,
// and calculate the size of the scroll container
this.__callback = this.getRenderFn();

View File

File diff suppressed because one or more lines are too long

View File

@@ -39,6 +39,8 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
hasScrollY: '@',
scrollbarX: '@',
scrollbarY: '@',
startX: '@',
startY: '@',
scrollEventInterval: '@'
},
@@ -84,6 +86,8 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
sv = new ionic.views.Scroll({
el: $element[0],
bouncing: enableBouncing,
startX: $scope.$eval($scope.startX) || 0,
startY: $scope.$eval($scope.startY) || 0,
scrollbarX: $scope.$eval($scope.scrollbarX) !== false,
scrollbarY: $scope.$eval($scope.scrollbarY) !== false,
scrollingX: $scope.$eval($scope.hasScrollX) === true,

View File

@@ -52,6 +52,11 @@
bottom: 10px;
width: 100%;
}
#search-box {
margin-bottom: 20px;
}
.scroll {
}
</style>
</head>
@@ -60,6 +65,7 @@
<header-bar id="header" title="'Title'" type="bar-primary" hides-header></header-bar>
<content id="container"
start-y="55"
on-scroll="onScroll(event, scrollTop, scrollLeft)"
on-scroll-complete="onScrollComplete(scrollTop, scrollLeft)"
on-refresh="onRefresh()"
@@ -69,6 +75,15 @@
has-tabs="true"
has-header="true"
>
<div id="search-box" class="bar bar-header item-input-inset">
<label class="item-input-wrapper">
<i class="icon ion-ios7-search placeholder-icon"></i>
<input type="search" placeholder="Search">
</label>
<button class="button button-clear">
Cancel
</button>
</div>
<button ng-click="add()">Click</button>
<ul class="list" ng-controller="AppCtrl">
<li class="list-item" ng-repeat="item in items">asdf{{$index}}</li>

View File

@@ -39,4 +39,14 @@ describe('Ionic Content directive', function() {
var scrollView = scope.scrollView;
expect(scrollView.options.bouncing).toBe(false);
});
it('Should set start x and y', function() {
element = compile('<content start-x="100" start-y="300" has-header="true"></content>')(scope);
timeout.flush();
var newScope = element.isolateScope();
var scrollView = scope.scrollView;
var vals = scrollView.getValues();
expect(vals.left).toBe(100);
expect(vals.top).toBe(300);
});
});

View File

@@ -299,6 +299,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
scrollingY: true,
scrollbarY: true,
startX: 0,
startY: 0,
/** The minimum size the scrollbars scale to while scrolling */
minScrollbarSizeX: 5,
minScrollbarSizeY: 5,
@@ -378,6 +381,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
});
};
this.__scrollLeft = this.options.startX;
this.__scrollTop = this.options.startY;
// Get the render update function, initialize event handlers,
// and calculate the size of the scroll container
this.__callback = this.getRenderFn();