ionic性能优化(1)

ionic-native-transitions

  1. 下载

    npm install ionic-native-transitions –save

  2. 安装

    cordova plugin add https://github.com/Telerik-Verified-Plugins/NativePageTransitions

  3. 引入

  4. 如果是ios9,页面切换抖动,则安装

    cordova plugin add cordova-plugin-wkwebvie

  5. 注入

    angular.module('yourApp', [ 
       'ionic-native-transitions' 
    ]); 
    
  6. 配置

    .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' 
       }); 
    }); 
  7. 其他参考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);
  // }
}

使用缓存

  1. 安装

    bower install –save angular-cache

  2. 注入

    angular.module(‘myApp’, [‘angular-cache’])

  3. 使用

    .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);
    
    })
  4. 详情请看https://github.com/jmdobry/angular-cache

使用Crosswalk WebView

  1. 安装

    cordova plugin add cordova-plugin-crosswalk-webview

  2. 如果使用了第一步优化,在config.xml加入

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值