Skip to content

Commit 27311d5

Browse files
committed
Added support for offset start scroll view
1 parent db6ce50 commit 27311d5

File tree

8 files changed

+48
-3
lines changed

8 files changed

+48
-3
lines changed

dist/js/ionic-angular.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,8 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
12291229
hasScrollY: '@',
12301230
scrollbarX: '@',
12311231
scrollbarY: '@',
1232+
startX: '@',
1233+
startY: '@',
12321234
scrollEventInterval: '@'
12331235
},
12341236

@@ -1274,6 +1276,8 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
12741276
sv = new ionic.views.Scroll({
12751277
el: $element[0],
12761278
bouncing: enableBouncing,
1279+
startX: $scope.$eval($scope.startX) || 0,
1280+
startY: $scope.$eval($scope.startY) || 0,
12771281
scrollbarX: $scope.$eval($scope.scrollbarX) !== false,
12781282
scrollbarY: $scope.$eval($scope.scrollbarY) !== false,
12791283
scrollingX: $scope.$eval($scope.hasScrollX) === true,

dist/js/ionic-angular.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/ionic.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,6 +2388,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
23882388
scrollingY: true,
23892389
scrollbarY: true,
23902390

2391+
startX: 0,
2392+
startY: 0,
2393+
23912394
/** The minimum size the scrollbars scale to while scrolling */
23922395
minScrollbarSizeX: 5,
23932396
minScrollbarSizeY: 5,
@@ -2467,6 +2470,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
24672470
});
24682471
};
24692472

2473+
this.__scrollLeft = this.options.startX;
2474+
this.__scrollTop = this.options.startY;
2475+
24702476
// Get the render update function, initialize event handlers,
24712477
// and calculate the size of the scroll container
24722478
this.__callback = this.getRenderFn();

dist/js/ionic.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/ext/angular/src/directive/ionicContent.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
3939
hasScrollY: '@',
4040
scrollbarX: '@',
4141
scrollbarY: '@',
42+
startX: '@',
43+
startY: '@',
4244
scrollEventInterval: '@'
4345
},
4446

@@ -84,6 +86,8 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
8486
sv = new ionic.views.Scroll({
8587
el: $element[0],
8688
bouncing: enableBouncing,
89+
startX: $scope.$eval($scope.startX) || 0,
90+
startY: $scope.$eval($scope.startY) || 0,
8791
scrollbarX: $scope.$eval($scope.scrollbarX) !== false,
8892
scrollbarY: $scope.$eval($scope.scrollbarY) !== false,
8993
scrollingX: $scope.$eval($scope.hasScrollX) === true,

js/ext/angular/test/content.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
bottom: 10px;
5353
width: 100%;
5454
}
55+
#search-box {
56+
margin-bottom: 20px;
57+
}
58+
.scroll {
59+
}
5560
</style>
5661

5762
</head>
@@ -60,6 +65,7 @@
6065
<header-bar id="header" title="'Title'" type="bar-primary" hides-header></header-bar>
6166

6267
<content id="container"
68+
start-y="55"
6369
on-scroll="onScroll(event, scrollTop, scrollLeft)"
6470
on-scroll-complete="onScrollComplete(scrollTop, scrollLeft)"
6571
on-refresh="onRefresh()"
@@ -69,6 +75,15 @@
6975
has-tabs="true"
7076
has-header="true"
7177
>
78+
<div id="search-box" class="bar bar-header item-input-inset">
79+
<label class="item-input-wrapper">
80+
<i class="icon ion-ios7-search placeholder-icon"></i>
81+
<input type="search" placeholder="Search">
82+
</label>
83+
<button class="button button-clear">
84+
Cancel
85+
</button>
86+
</div>
7287
<button ng-click="add()">Click</button>
7388
<ul class="list" ng-controller="AppCtrl">
7489
<li class="list-item" ng-repeat="item in items">asdf{{$index}}</li>

js/ext/angular/test/directive/ionicContent.unit.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,14 @@ describe('Ionic Content directive', function() {
3939
var scrollView = scope.scrollView;
4040
expect(scrollView.options.bouncing).toBe(false);
4141
});
42+
43+
it('Should set start x and y', function() {
44+
element = compile('<content start-x="100" start-y="300" has-header="true"></content>')(scope);
45+
timeout.flush();
46+
var newScope = element.isolateScope();
47+
var scrollView = scope.scrollView;
48+
var vals = scrollView.getValues();
49+
expect(vals.left).toBe(100);
50+
expect(vals.top).toBe(300);
51+
});
4252
});

js/views/scrollView.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
299299
scrollingY: true,
300300
scrollbarY: true,
301301

302+
startX: 0,
303+
startY: 0,
304+
302305
/** The minimum size the scrollbars scale to while scrolling */
303306
minScrollbarSizeX: 5,
304307
minScrollbarSizeY: 5,
@@ -378,6 +381,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
378381
});
379382
};
380383

384+
this.__scrollLeft = this.options.startX;
385+
this.__scrollTop = this.options.startY;
386+
381387
// Get the render update function, initialize event handlers,
382388
// and calculate the size of the scroll container
383389
this.__callback = this.getRenderFn();

0 commit comments

Comments
 (0)