File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -268,7 +268,7 @@ export class Content extends Ion {
268
268
* @returns {Promise } Returns a promise which is resolved when the scroll has completed.
269
269
*/
270
270
scrollToTop ( duration : number = 300 ) {
271
- return this . scrollTo ( 0 , 0 , duration ) ;
271
+ return this . _scroll . scrollToTop ( duration ) ;
272
272
}
273
273
274
274
/**
@@ -287,6 +287,15 @@ export class Content extends Ion {
287
287
this . _scroll . setTop ( top ) ;
288
288
}
289
289
290
+ /**
291
+ * Scroll to the bottom of the content component.
292
+ * @param {number } [duration] Duration of the scroll animation in milliseconds. Defaults to `300`.
293
+ * @returns {Promise } Returns a promise which is resolved when the scroll has completed.
294
+ */
295
+ scrollToBottom ( duration : number = 300 ) {
296
+ return this . _scroll . scrollToBottom ( duration ) ;
297
+ }
298
+
290
299
/**
291
300
* @private
292
301
*/
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ class MyCmpTest{}
48
48
<button ion-item (click)="quickPush()">New push during transition</button>
49
49
<button ion-item (click)="quickPop()">New pop during transition</button>
50
50
<button ion-item (click)="reload()">Reload</button>
51
+ <button ion-item (click)="scrollToBottom()">Scroll to bottom</button>
51
52
<button *ngFor="#i of pages" ion-item (click)="pushPrimaryHeaderPage()">Page {{i}}</button>
52
53
<button ion-item (click)="content.scrollToTop()">Scroll to top</button>
53
54
</ion-list>
@@ -121,6 +122,10 @@ class FirstPage {
121
122
scrollToTop ( ) {
122
123
this . content . scrollToTop ( ) ;
123
124
}
125
+
126
+ scrollToBottom ( ) {
127
+ this . content . scrollToBottom ( 1000 ) ;
128
+ }
124
129
}
125
130
126
131
Original file line number Diff line number Diff line change @@ -104,6 +104,18 @@ export class ScrollView {
104
104
} ) ;
105
105
}
106
106
107
+ scrollToTop ( duration : number ) : Promise < any > {
108
+ return this . scrollTo ( 0 , 0 , duration ) ;
109
+ }
110
+
111
+ scrollToBottom ( duration : number ) : Promise < any > {
112
+ let y = 0 ;
113
+ if ( this . _el ) {
114
+ y = this . _el . scrollHeight - this . _el . clientHeight ;
115
+ }
116
+ return this . scrollTo ( 0 , y , duration ) ;
117
+ }
118
+
107
119
stop ( ) {
108
120
this . isPlaying = false ;
109
121
}
You can’t perform that action at this time.
0 commit comments