ionic性能优化(1)
ionic-native-transitions下载npm install ionic-native-transitions –save安装cordova plugin add https://github.com/Telerik-Verified-Plugins/NativePageTransitions引入如果是ios9,页面切换抖动,则安装cordova plugin add cor
·
ionic-native-transitions
下载
npm install ionic-native-transitions –save
安装
cordova plugin add https://github.com/Telerik-Verified-Plugins/NativePageTransitions
引入
如果是ios9,页面切换抖动,则安装
cordova plugin add cordova-plugin-wkwebvie
注入
angular.module('yourApp', [ 'ionic-native-transitions' ]);
配置
.config(function($ionicNativeTransitionsProvider){ $ionicNativeTransitionsProvider.setDefaultOptions({ duration: 400, // in milliseconds (ms), default 400, slowdownfactor: 4, // overlap views (higher number is more) or no overlap (1), default 4 iosdelay: -1, // ms to wait for the iOS webview to update before animation kicks in, default -1 androiddelay: -1, // same as above but for Android, default -1 winphonedelay: -1, // same as above but for Windows Phone, default -1, fixedPixelsTop: 0, // the number of pixels of your fixed header, default 0 (iOS and Android) fixedPixelsBottom: 0 // the number of pixels of your fixed footer (f.i. a tab bar), default 0 (iOS and Android) triggerTransitionEvent: '$ionicView.afterEnter', // internal ionic-native-transitions option backInOppositeDirection: false // Takes over default back transition and state back transition to use the opposite direction transition to go back }); $ionicNativeTransitionsProvider.setDefaultTransition({ type: 'slide', direction: 'left' }); $ionicNativeTransitionsProvider.setDefaultBackTransition({ type: 'slide', direction: 'right' }); });
其他参考https://github.com/shprink/ionic-native-transitions 或者pdf
删除默认滚动条
.config(function($ionicConfigProvider) {
$ionicConfigProvider.scrolling.jsScrolling(false);
// Or for only a single platform, use
// if( ionic.Platform.isAndroid() ) {
// $ionicConfigProvider.scrolling.jsScrolling(false);
// }
}
使用缓存
安装
bower install –save angular-cache
注入
angular.module(‘myApp’, [‘angular-cache’])
使用
.controller('Posts', function (CacheFactory) { if (!CacheFactory.get('postCache')) { CacheFactory.createCache('postCache'); } var postCache = CacheFactory.get('postCache'); // Cache a post postCache.put(id, data); // Delete from cache postCache.remove(id); // Get a post $scope.post = postCache.get(id); })
使用Crosswalk WebView
安装
cordova plugin add cordova-plugin-crosswalk-webview
如果使用了第一步优化,在config.xml加入
更多推荐
已为社区贡献1条内容
所有评论(0)