Search code examples
nativescriptnativescript-angular

How to detect if the scrollview stops scrolling in nativescript angular?


Iam developing android and ios application using nativescript angular.Iam using scrollview to show list items.Is there anyway to detect if user stopped scrolling in scrollview? Please provide any solution for this.


Solution

  • You could listen to the touch event and make sure event.action is TouchAction.up.

    Edit: If you want to attach your own implementation of UIScrollViewDelegate on iOS, you could do this. My version of delegate accepts the original delegate as a parameter, so I don't loose anything that is already implemented in the original delegate.

    (<any>ScrollView.prototype).originalAttachNative = (<any>ScrollView.prototype).attachNative;
    (<any>ScrollView.prototype).attachNative = function () {
        this.originalAttachNative();
        const newDelegate = MyUIScrollViewDelegateImpl.initWithOriginalDelegate(this._delegate);
        this._delegate = newDelegate;
        this.nativeViewProtected.delegate = newDelegate;
    };