Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scrollToTop() doesn't work on iOS in v2 #6975

Closed
battistaar opened this issue Jun 20, 2016 · 4 comments
Closed

scrollToTop() doesn't work on iOS in v2 #6975

battistaar opened this issue Jun 20, 2016 · 4 comments

Comments

@battistaar
Copy link

Short description of the problem:

Calling scrollToTop() on a Content element (or other classes that use ScrollView) doesn't scroll on iOS.

What behavior are you expecting?

The content to scroll up to the top.

Steps to reproduce:

  1. Reference a Content element in a component
  2. call element.scrollToTop()

Other information:
I think the problem is in scroll-view.ts in scrollTo method.
At line 51 it should call self.getTop() to get the actual scrollTop position, doing that it takes care of the "js" check.
I changed it in my project and it seems to work.

Which Ionic Version? 1.x or 2.x
Ionic 2 Beta 9

Run ionic info from terminal/cmd prompt:
Cordova CLI: 6.2.0
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.9
Ionic CLI Version: 2.0.0-beta.30
Ionic App Lib Version: 2.0.0-beta.16
ios-deploy version: 1.8.6
ios-sim version: 5.0.3
OS: Mac OS X El Capitan
Node Version: v6.0.0
Xcode version: Xcode 7.3.1 Build version 7D1014

@jgw96
Copy link
Contributor

jgw96 commented Jun 20, 2016

Hello thanks for reopening the issue! Would you mind posting a plunker that gives a minimal example of this issue? Thanks for using Ionic!

@jgw96 jgw96 added the needs: reply the issue needs a response from the user label Jun 20, 2016
@battistaar
Copy link
Author

I realized that using Content component works fine (even in nested Content instances).

In my project I was trying to add a method to the virtual-scroll component to scroll the list to the top using the _content field of the class. It worked fine on browser but not on iOS, making the changes I have written above it works properly both on browser and iOS.

I do not know why this different behavior, I'll do some more tests as soon as possible, but I think it's actually a bug, in the source there are:

getTop(): number { ... }
and
setTop(top: number) { ... }

that take care of the different scroll behavior between iOS and other platforms.

Later in the same same file in scrollTo method setTop is used to scroll, but fromY is miscalculated at line 51.

In my opinion it should be

let fromY = self.getTop();

It would be useful to have a scrollToTop method for virtualscrolls, do you know if there is another way to do that?

@Ionitron Ionitron removed the needs: reply the issue needs a response from the user label Jun 21, 2016
@jgw96
Copy link
Contributor

jgw96 commented Jun 24, 2016

Hello at this time there is not a scrollToTop method for VirtualScroll, but i will make an issue for this feature and link to it here so you can find it. Since it seems that scrollToTop is working fine for a regular list i will be closing this issue and focusing on getting it working with VirtualScroll in the other issue. Thanks for using Ionic!

@jgw96 jgw96 closed this as completed Jun 24, 2016
@jgw96
Copy link
Contributor

jgw96 commented Jun 24, 2016

Also, would you be able to make a plunker that shows your issues with using scrollToTop with virtualscroll? Thanks!

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants