ionic-team / ionic-v1

The repo for Ionic 1.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
Other
193 stars 187 forks source link

native scroll does not update getScrollPosition() unless scroll event is issued #243

Open jgw96 opened 7 years ago

jgw96 commented 7 years ago

From @vance on May 12, 2016 0:42

Note: If you are having problems formatting your issue please refer to this article on using markdown in Github:

https://guides.github.com/features/mastering-markdown/

Note: for support questions, please use one of these channels:

https://forum.ionicframework.com/ http://ionicworldwide.herokuapp.com/

Short description of the problem:

I have a timer check the position of an ion-scroll. I trace this to the screen. I need the realtime top/left values to compute other actions. This works fine in the browser using trackpad, however, on iOS, the value is only updated intermittently, which causes jumping and inconsistent behavior for my other maths. It seems to only update when the user is actively dragging, that is, it does not take into account the deceleration.

What behavior are you expecting?

I would expect it to be a continuous value when called from a setInterval(). I'd suggest having this function return both the target value and the current value as their own properties.

the getScrollPosition() should be continuously updated.

Steps to reproduce:

  1. print the value of left coordinate from a scrollDelegate to a fixed div so you can watch it's value in realtime
  2. scroll fast so there's deceleration
  3. note that the value does not update until you touch it again
insert any relevant code between the above and below backticks

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

Which Ionic Version? 1.2.4

Plunker that shows an example of your issue

can't plunker, it's iOS only.

Copied from original issue: driftyco/ionic#6506

jgw96 commented 7 years ago

From @vance on May 12, 2016 7:6

I see that getValues: function() does not call this.update() first like some of the other getters. Just a suggestion. I'll try it. update: nope, that did not work...

I may have a hacky workaround which is to simply measure the window-relative position of an element at [0,0] in the scroll area with the js api, divContainer.getBoundingClientRect().left but, of course values will be negative/inverse since they are relative to the window and not the content.

jgw96 commented 7 years ago

From @vance on May 12, 2016 7:31

Even calling DOM API functions like divContainer.getBoundingClientRect().left; from a timer only works in the browser. On iOS, values don't update until the deceleration stops or you touch the pane. Is this a limitation of native scroll? how could one properly measure the position? This needs to be accurate as this is basically a map application.

jgw96 commented 7 years ago

From @FlavorScape on May 13, 2016 5:49

I would be satisfied if we could simply bubble this iOS UIScrollView property to ionic. How might I do that myself?

UIScrollView --> targetContentOffset

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScrollViewDelegate_Protocol/index.html#//apple_ref/doc/uid/TP40006923-CH3-SW15

jgw96 commented 7 years ago

From @danielcrk-cn on May 16, 2016 9:27

It would be amazing to be able to get native scroll events of the WebView, as it would probably support overscroll as well. Then we could be able to create alot more native-like "pull to refresh", create elastic headers etc.

jgw96 commented 7 years ago

From @vance on May 25, 2016 23:34

Alas, native scroll crashes if you zoom out too far, so i'd like to adjust zoom while scrolling.... but i can't get continuous scroll events from native scroll :(

jgw96 commented 7 years ago

From @vance on October 27, 2016 0:17

Anything? I'm still having this issue with Ionic.