-
Notifications
You must be signed in to change notification settings - Fork 107
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
Scroller is still updating in hidden tabs / states #83
Comments
I have investigated the issue, thank you! The cause of this issue is that no viewport directive is being used in your demo and the global "window" acts as a viewport for both scrollers. And thus we have a scroll-event subscription which works for both scrollers: We need a little time to think of how this could be fixed. |
A simple fix for this problem would be to use ui-scroll-viewport directive to introduce separate viewports to each scroller |
Is it possible to use the ui-scroll-viewport directive without specifiying a fixed height? For example:
If the directive will introduce a seperate scroll area (not using the browsers scroll area) this will not work for my usecase. |
The viewport height has to be constrained |
I did a commit on this issue. And prepared a demo: http://rawgit.com/angular-ui/ui-scroll/master/demo/disabled/disabled.html. With it you can subscribe on selectedIndex changes and call .disable() on the adapter when selectedIndex does not match scroller instance. Something like
for first tab controller and
for second tab controller. |
would it be better to have a property (call it enabled) instead? Among other things this would allow for checking the property. |
First of all thank you for the possiblity to disable the scroller. I thought a lot about how I could detect if a specific scroller becomes invisible/visible. For my plunker it is easy and works as you have suggested: Both tabs are active and I can simply switch the tab index. But in my case I have a bottom navigation and a top navigation. The first tab of the bottom navigation can contain none scroller, one scroller or multiple scrollers. From this point the user can navigate to an 'endless' chain of views within the tab (and can also navigate back to previous views). For example |
Per Mike's request I replaced
Here you can obtain full demo of this feature: http://rawgit.com/angular-ui/ui-scroll/master/demo/disabled/disabled.html. This will be included in next release. Regarding to your last comment, if I understood it correctly, just have a property (or set of properties) on scope that reflects the navigation state of your app and bind it to "disabled" attribute in appropriate relation. |
Oh damn, somehow my response was not been sent :( Here again: I use ui-router and ui-router-extras to handle the states of my application. I tried to save the state that belongs to the controller on initialization and also added an event listener:
I am using the deep state redirect feature of ui-router extras (https://christopherthielen.github.io/ui-router-extras/#/dsr). Because of that I can not use '$stateChangeStart' and have to wait for '$stateChangeSuccess' to access the final state transition (for example: If you hit the feed tab 'home.feed' is getting redirected to the last active state of the tab 'home.feed.likes'). The problem is during the time span where the state change is happening ui-scroll is already requesting new data and before the '$stateChangeSuccess' event the view gets rendered -> the scroller is setting y-pos to 0. Besides that I am currently using a routing service that takes care about everything related to states. If I can find a solution for the first problem I am still mixing controller logic with states. |
This will prevent initialization process itself while your state doesn't match necessary tab. |
If I understand you correctly the current solution should fit my router service behaviour:
I interpret from your response that the scroller should be able to react to the '$window.scrollTo' action even if it is disabled. But for some reason each time I go back to an previous active state the scroll position is different. In combination with the simple infinite scroll plugin I used previously it worked as expected. If you confirm my interpretation the problem should be my own router logic. For the problem where the scroller is still active during state transition and requests new data I still couldn't find a solution as well. |
If |
Data-fetch: I got you. The first time data fetch is fine. The problem is the data fetch when changing from one tab to another but this is a problem with my own code. I need to disable the scroller somehow before state transitions take place. |
Ok! So there's no problem with "disable" itself as I can see and we are close to finish this issue. Regarding to $window.scrollTo, I'm still not sure if I understood you properly, but if you think we can help you from the side of the directive, you may open a new issue and a repro would be preferably... |
I use your scroller plenty times in my app. It is nested in different tabs that can contain multiple states (some states include a scroller, some do not). The problem is all states stay active in background. When I change from one tab to another the scroller is still reacting to scroll events. That means if I open 3 tabs containing a scroller, all 3 scrollers are still reacting to scroll events simultaneously, even if the opened tab does not contain an own scroller.
Here is a simple plnkr with 2 tabs and 1 scroller per tab:
https://plnkr.co/edit/MUgEKBOnQng170YLtEvs
The text was updated successfully, but these errors were encountered: