I have the need that I trigger a scroll to bottom once a new line gets added to the listview. This should be triggered by code but so far I have not found a good solution.
So far my solution is:
scrollViewToBottom: function (view) {
var scroller = view.scroller;
console.log("scrollheight " + scroller.scrollHeight() + " height: " + scroller.height());
var offset = scroller.height();
if (offset == 0)
offset = 100;
scroller.scrollTo(0, scroller.scrollHeight() * -1 + offset);
},
but this does not work in most scenarious because scroller.scrollHeight and scroller.height don't seem to be initialized.
Is there any better solution to this?
Christoph
So far my solution is:
scrollViewToBottom: function (view) {
var scroller = view.scroller;
console.log("scrollheight " + scroller.scrollHeight() + " height: " + scroller.height());
var offset = scroller.height();
if (offset == 0)
offset = 100;
scroller.scrollTo(0, scroller.scrollHeight() * -1 + offset);
},
but this does not work in most scenarious because scroller.scrollHeight and scroller.height don't seem to be initialized.
Is there any better solution to this?
Christoph