How can I get the scroll event?


#1

Hi Al,

I would like to perform some action when the user scrolling the page, if he scrolls down I will perform an action and if he scrolls up I will implement another. How can I do that ???


#2

Hey @sagar1911 please be more specific. What view are you trying to scroll? The ScrollView? A StackLayout? Any layout?

Perhaps you are interested in subscribing to Pan gestures? If that’s the case, have a look at the Gestures article - https://docs.nativescript.org/ui/gestures#pan


#3

Hi Sir,
ScrollView

Thanks for the response.


#4

In that case the Swipe or Pan gestures from the article should do just what you want. I am just not certain whether attaching a swipe/pan gesture to the scrollview won’t disable the scrollview’s “scrolling” behavior. If it does, consider using a StackLayout which you manipulate manually with the swipe/pan gestures handling.


#5

Okay sir, I’ll try and get back to you.


#6

Sir,
will pan gestures for every element ??
I have tried for scroll view and page but the application is not starting.

Here is my code for page element.

var gestures = require(“ui/gestures”);
var page = args.object;
page.on(gestures.GestureTypes.pan, function (args) {
console.dir(“Pan deltaX:” + args.deltaX + “; deltaY:” + args.deltaY + “;”);
});


#7

Can I get the scrolling top, scrolling bottom actions from the scrollview ??
I don’t know whether my question making much sense or not .!! but I want that activity in my project.
When he touch to scrolls up I would like to enable the header section, and when he touch to scrolls down I would like to disable it.
Is there any alternative ??


#8

Okay. It worked :slight_smile: