keerl
keerl

Reputation: 116

Nativescript RadListView Scroll to Bottom with footer

I am using RadListView and am trying to programmatically scroll to the bottom of the list. I am able to use the scrollToIndex() function to scroll to the last element in the list, but my list has a footer and I need to scroll past that as well. I can't figure out a clean way to do that besides scrolling to the last element and then do a scrollWithAmount() with the height of the footer. That way doesn't work the greatest and I feel like there should be a better way.

Here is a Playground showing the issue.

Upvotes: 0

Views: 383

Answers (1)

Manoj
Manoj

Reputation: 21898

To scroll to the bottom most of the RadListView, you may simply calculate it's height and scroll with amount.

    let to;
    if (this.radList.ios) {
        const collectionView = this.radList.nativeViewProtected.collectionView;
        to = Math.max(0, collectionView.contentSize.height - collectionView.bounds.size.height);
    } else {
        to = layout.toDevicePixels(this.radList.getMeasuredHeight());
    }
    this.radList.scrollWithAmount(to, false);

Updated Playground

Upvotes: 1

Related Questions