Hi All,
I am using Ionic2.
I have a list of items. On an event (messageSend function called), I would like to scroll to the top of the list.
messages.html
<ion-content padding class="messages-page-content">
<ion-scroll scrollY="true" class="messages">
<ion-list class="message-list">
<ion-item ....
messages.ts
messageSend(va, vi) {
// scroll to top of list
}
Any advise appreciated.
with ion-scroll I would do
@ViewChild('yourScroll') scrollY: Scroll;
this.scrollY.scrollElement.scrollTop = 0;
reedrichards:
‘yourScroll’
Thanks, just a quick question, what is 'yourScroll'? Where should that be defined?
ps. Also can you scroll to the bottom rather?
<ion-scroll #yourScroll scrollY="true" class="messages">
Thank you
Looking at scrollElement, is it possible to rather scroll to the bottom?
to scroll to the bottom then I guess you have to play with the scrollElement, there is probably a property which give you the current height, just assign then the scrollBottom to that height
side note, what you could also do, if it is possible in your case, is to get rid of using an ion-scroll and just scrollToBottom() of the content