How to stop scrolling during scroll event?


#1

Hi everyone,

When ion-content is scrolling and I click scrollToTop(). It goes to top first, and then jump back to where it was. I think it’s because the previous scrolling is not finished, so it continues after scrollToTop() finished… How can I fix this? Is there a way to stop ion-content scrolling during scroll event?

Thanks!

Here is my code for scroll to top:

in ts file:

import {  Content  } from 'ionic-angular';

...

export class TodayDealsPage {

	@ViewChild(Content) content: Content;

...

	ionSelected() {
	    this.content.scrollToTop();
	}
}


#2

Hi, I search to fix the same issue. Do you have find any solution?


#3

I think I did. But I forgot how I did it. I look at my code and see I added if(this.content._scroll). But I can’t remember why and how it works…

import {  Content  } from 'ionic-angular';

...

export class TodayDealsPage {

	@ViewChild(Content) content: Content;

...

	ionSelected() {
		if(this.content._scroll) {
			this.content.scrollToTop();
		}
	}
}