cordova原生頁面切換效果插件的使用:com.telerik.plugins.nativepagetransitions

1. 添加插件:cordova plugin add com.telerik.plugins.nativepagetransitions
2. 使用方法:html

在index.html中添加:android

<meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src  'self' 'unsafe-inline' *">
app.run(function($ionicPlatform) {
    $ionicPlatform.ready(function() {
        // then override any default you want
        window.plugins.nativepagetransitions.globalOptions.duration = 500;
        window.plugins.nativepagetransitions.globalOptions.iosdelay = 350;
        window.plugins.nativepagetransitions.globalOptions.androiddelay = 350;
        window.plugins.nativepagetransitions.globalOptions.winphonedelay = 350;
        window.plugins.nativepagetransitions.globalOptions.slowdownfactor = 4;
        // these are used for slide left/right only currently
        window.plugins.nativepagetransitions.globalOptions.fixedPixelsTop = 0;
        window.plugins.nativepagetransitions.globalOptions.fixedPixelsBottom = 0;
    });
});
$state.go('view', {movieid: id});   
window.plugins.nativepagetransitions.slide(
  {"direction":"up"},
  function (msg) {console.log("success: " + msg)}, // called when the animation has finished
  function (msg) {alert("error: " + msg)} // called in case you pass in weird values
);

3. 取消默認的動畫:ios

$ionicConfigProvider.views.transition('no');

4. 若是不但願哪一個頁面有動畫也能夠禁用某個頁面的動畫效果:app

.state('tab.message', {
        url: '/message',
        nativeTransitions: null,         cache:false,
        views: {
            'tab-message': {
                templateUrl: 'templates/tab-message.html',
                resolve: load([
                    'js/services/commonusefunction/messagesFactory.js',                    
                    'js/controllers/messageController.js',
                    'js/services/public/ionicModalService.js'
                ])
            }
        }
 })

5. 設置點擊進入某個頁面時候的動畫:ionic

.config(function($ionicNativeTransitionsProvider){
    $ionicNativeTransitionsProvider.setDefaultBackTransition({
        type: 'slide',
        direction: 'right'
    });
});

6.  您還能夠根據這樣的設備定義不一樣的轉換(向後和向前):ide

.state('home', {
    url: '/home',
    nativeTransitionsAndroid: {
        "type": "flip",
        "direction": "right"
    },
    nativeTransitionsIOS: {
        "type": "flip",
        "direction": "left"
    },
    nativeTransitionsWindowsPhone: {
        "type": "flip",
        "direction": "down"
    },
    nativeTransitionsBackAndroid: {
        "type": "flip",
        "direction": "left"
    },
    nativeTransitionsBackIOS: {
        "type": "flip",
        "direction": "right"
    },
    nativeTransitionsBackWindowsPhone: {
        "type": "flip",
        "direction": "up"
    },
    templateUrl: "templates/home.html"
})
相關文章
相關標籤/搜索