Ionic owes much of its early success to Javascript Scrolling. Since earlier mobile browsers didn’t allow for proper native scroll events, JS scrolling was essential for things like Pull To Refresh, Infinite Scrolling, List Reordering, and Collection Repeat.
Well, mobile browsers have come a long way in this regard. Android 4.1+ supports native scroll events. With Ionic adding Crosswalk support, they work even better. iOS admittedly, is a bit late to the scroll event party. WKWebView in iOS8 supports native scroll events, but hybrid apps cannot yet take advantage of WKWebView without some hacky solutions that break things like ajax requests and plugins. So for now, this post is for those developing for Android. Sorry, iOS devs, soon. Please hassle any Apple employees on the iOS team that you may know.
It is time to begin phasing out JS scrolling for Android! While JS scrolling has served us well, it eats up processor and GPU time that can be better spent making increasingly beautiful apps. We’re going to do this component by component, and we will not change the default away from JS scrolling until we’re convinced that native scrolling is ready for prime time. That’s where you come in!
We’ve added a new ionicConfig
setting to enable native scrolling. It essentially does the same thing as overflow-scroll="true"
on ion-content
does. It can be set from the config phase of the app like so:
angular.module('ionicApp', ['ionic']).config(function($ionicConfigProvider) {
if(!ionic.Platform.isIOS())$ionicConfigProvider.scrolling.jsScrolling(false);
})
We’re going to be adding native scrolling support component by component. So far, infinite scrolling and the refresher should work. We’ll be adding support for collection-repeat and list reordering soon.
Your mission, should you choose to accept it, is to grab a nightly version of Ionic, try out native scrolling on your app using the config above, and let us know what does and doesn’t work.
To clarify, this is strictly related to seeing how native scrolling works in comparison to JS scrolling regarding infinite scrolling and pull to refresh.
Let me know what you think. If you have something that is broken, try to reproduce it in a codepen or something we can use to reproduce and inspect the problem.
Cheers