https://github.com/shprink/ionic-native-transitions
https://www.npmjs.com/package/ionic-native-transitions
這個是ionic1的, 推薦使用ionic2開發, 或者ionic-nativecss
直接使用ionic的css動畫, 頁面數據較多的時候簡直卡成翔了, 使用分頁加載也沒有太大的改善.
目前最佳方案是使用[]ionic-native-transitions插件](https://github.com/shprink/ionic-native-transitions)html
# npm npm install ionic-native-transitions --save # Using Ionic CLI ionic cordova plugin add https://github.com/Telerik-Verified-Plugins/NativePageTransitions#0.6.5 # 報錯Probably this is either a connection problem, or plugin spec is incorrect. # 使用--nofetch來成功安裝 cordova plugin add https://github.com/Telerik-Verified-Plugins/NativePageTransitions#0.6.5 --save --nofetch
能夠將ionic-native-transitions目錄copy到www\lib下, 再在index.html中引入android
<script src="lib/ionic-native-transitions/dist/ionic-native-transitions.min.js"></script>
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.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' }); });
若是你用了crosswork記得config.xml中添加:
Android
if you are using Crosswalk > 1.3 please add the following to your config.xmlios
<preference name="CrosswalkAnimatable" value="true" />
咱們不指望tab也出現這個切換效果, 禁用tab先的動畫git
.state('home', { url: '/home', nativeTransitions: null, templateUrl: "templates/home.html" })