ionic native transitions

2025-12-07 0 975

离子V1的天然过渡。打开它并享受本地过渡!

请注意,该项目现在处于维护模式。我们欢迎PRS进行错误修复,但鼓励您使用离子2和离子本机进行未来的所有开发。

聊天

安装

NPM

https://www.**npmj*s.com/package/ionicnativetransitions

 npm install ionic-native-transitions --save

然后需要库

# ES5
require ( \'ionic-native-transitions\' ) ;

# or ES6
import \'ionic-native-transitions\' ; 

鲍尔

 bower install shprink/ionic-native-transitions

然后插入DIST文件

 <script src=\"./PathToBowerLib/dist/ionic-native-transitions.min.js\"></script>

科尔多瓦/离子

过渡插件的推荐版本为0.6.5或更高。

 # Using Cordova
cordova plugin add https://g*it*hub.*com/Telerik-Verified-Plugins/NativePageTransitions#0.6.5

# Using Ionic CLI
ionic plugin add https://g*it*hub.*com/Telerik-Verified-Plugins/NativePageTransitions#0.6.5

ios

iOS9上的过渡有时会闪烁。为了防止此操作,您可以安装此插件:

 # Using Cordova
cordova plugin add cordova-plugin-wkwebview

# Using Ionic CLI
ionic plugin add cordova-plugin-wkwebview

安卓

如果您使用的是人行横道> 1.3,请在config.xml中添加以下内容

 <preference name=\"CrosswalkAnimatable\" value=\"true\" />

配置

 angular . module ( \'yourApp\' , [
    \'ionic-native-transitions\'
] ) ; 

设置默认选项(可选)

当心:如果知道自己在做什么,则仅使用setDefaultOptions

 . 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
    } ) ;
} ) ; 

设置默认过渡(可选)

查看可能的过渡列表

 . config ( function ( $ionicNativeTransitionsProvider ) {
    $ionicNativeTransitionsProvider . setDefaultTransition ( {
        type : \'slide\' ,
        direction : \'left\'
    } ) ;
} ) ; 

设置默认返回过渡(可选)

查看可能的过渡列表

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

启用/禁用(可选)

您可以根据任何原因在编程中禁用插件:

# Within the config phase
# * @ param { boolean } enabled
$ionicNativeTransitionsProvider . enable ( false ) ;

# Anywhere else ( controller , service etc . )
# * @ param { boolean } enabled                    default true
# * @ param { boolean } disableIonicTransitions    default true
# * @ param { string }  ionicTransitionType        default \'platform\'

# Disable plugin and enable ionic transitions ( same as : enable ( false , false ) )
$ionicNativeTransitions . enable ( false ) ;

# Enable plugin and disable ionic transitions ( same as : enable ( true , true ) )
$ionicNativeTransitions . enable ( true ) ;

# Disable plugin and disable ionic transitions
$ionicNativeTransitions . enable ( false , true ) ;

# Enable plugin and enable ionic transitions
# in some cases it is useful < https : / / github . com / shprink / ionic - native - transitions / issues / 23 >
$ionicNativeTransitions . enable ( true , false ) ;

用法

默认情况下,任何状态转换都将使用默认过渡(在配置阶段定义),但是如果您想使用UI路由器状态定义:

 . state ( \'home\' , {
    url : \'/home\' ,
    nativeTransitions : {
        \"type\" : \"flip\" ,
        \"direction\" : \"up\"
    }
    templateUrl : \"templates/home.html\"
} )

您还可以根据这样的设备定义不同的过渡(向后和向前):

 . 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\"
} )

覆盖只有一个设备(这里只有Android会不同)

 . state ( \'home\' , {
    url : \'/home\' ,
    nativeTransitions : {
        \"type\" : \"flip\" ,
        \"direction\" : \"up\"
    } ,
    nativeTransitionsAndroid : {
        \"type\" : \"flip\" ,
        \"direction\" : \"right\"
    }
    templateUrl : \"templates/home.html\"
} )

禁用一个状态的本机过渡(例如在选项卡上)

 . state ( \'home\' , {
    url : \'/home\' ,
    nativeTransitions : null ,
    templateUrl : \"templates/home.html\"
} ) 

通过本机过渡在编程上更改页面

状态

# * @ description
# * Call state go and apply a native transition
# * @ param { string | null } state                default : null
# * @ param { object }      stateParams          default: { }
# * @ param { object }      stateOptions         default: { }
# * @ param { object | null } transitionOptions    default : null

$ionicNativeTransitions . stateGo ( \'yourState\' , { } , { } , {
    \"type\" : \"slide\" ,
    \"direction\" : \"up\" , // \'left|right|up|down\', default \'left\' (which is like \'next\')
    \"duration\" : 1500 , // in milliseconds (ms), default 400
} ) ;

location.url

# * @ description
# * Call location url and apply a native transition
# * @ param { string | null } url                 default : null
# * @ param { object | null } transitionOptions   default : null

$ionicNativeTransitions . locationUrl ( \'/yourUrl\' , {
    \"type\" : \"slide\" ,
    \"direction\" : \"down\" , // \'left|right|up|down\', default \'left\' (which is like \'next\')
    \"duration\" : 1500 , // in milliseconds (ms), default 400
} ) ; 

使用指令

 < button native-ui-sref =\" tabs.home({param1: \'param1\', param2: \'param2\'}) \" native-ui-sref-opts =\" {reload: true} \" native-options =\" {type: \'slide\', direction:\'down\'} \" > </ button > 

历史记录后按钮

如果您没有在其上添加特定的ng-click则使用<ion-nav-back-button>指令会自动使用默认的后退过渡。

有软件后按钮(Android)

Android上的硬件返回按钮使用默认的后背过渡

向后滑动(iOS)

现在,滑动将触发状态本机过渡(或默认)。它不使用背部过渡。

您可以这样禁用滑动:

 $ionicConfigProvider . views . swipeBackEnabled ( false ) ; 

事件

您可以收听成功或错误事件

 $rootScope . $on ( \'ionicNativeTransitions.beforeTransition\' , function ( ) {
    // Transition is about to happen
} ) ;

$rootScope . $on ( \'ionicNativeTransitions.success\' , function ( ) {
    // Transition success
} ) ;

$rootScope . $on ( \'ionicNativeTransitions.error\' , function ( ) {
    // Transition error
} ) ;

可能的过渡

幻灯片(默认动画)

 {
    \"type\"          : \"slide\" ,
    \"direction\"     : \"left\" , // \'left|right|up|down\', default \'left\' (which is like \'next\')
    \"duration\"      :  500 , // in milliseconds (ms), default 400
} 

翻动

 {
    \"type\"          : \"flip\" ,
    \"direction\"     : \"up\" , // \'left|right|up|down\', default \'right\' (Android currently only supports left and right)
    \"duration\"      :  500 , // in milliseconds (ms), default 400
} 

淡入(仅iOS和Android)

 {
    \"type\"          : \"fade\" ,
    \"duration\"      :  500 , // in milliseconds (ms), default 400
} 

抽屉(仅iOS和Android)

 {
    \"type\"          : \"drawer\" ,
    \"origin\"        : \"left\" , // \'left|right\', open the drawer from this side of the view, default \'left\'
    \"action\"        : \"open\" , // \'open|close\', default \'open\', note that close is not behaving nicely on Crosswalk
 } 

卷曲(仅iOS,仅上下方向)

 {
    \"type\"          : \"curl\" ,
    \"direction\"     : \"up\" , // \'up|down\', default \'up\'
}

常问问题

动画标签的最佳方法是什么?

使用褪色过渡

 . state ( \'tabs.contact\' , {
    url : \"/contact\" ,
    nativeTransitions : {
        type : \"fade\"
    }
} )

如果要使用幻灯片,请将其与fixedPixelsTop选项一起使用。

 . state ( \'tabs.contact\' , {
    url : \"/contact\" ,
    nativeTransitions : {
        type : \"slide\" ,
        direction : \"left\" ,
        fixedPixelsTop : 93
    }
} )

贡献

发展

 npm install

# Open two terminals
# and run watch to build on the lib files changes
npm run watch

# in the other terminal run following to build the test page and the doc
npm start

打开http://loc*alhos*t*:8080

在设备上进行测试

 npm run platformAddAndroid
npm run platformAddIOS
npm run pluginAddAll

# run iOS devices
npm run runIosDevice

# run iOS devices
npm run runAndroid

谢谢

  • Eddy Verbruggen的出色工作:https://github.com/telerik-verified-plugins/nativepagetransitions
  • Gajotres的出色帖子:http://www.gajotres.net/handling-native-native-view-animations-with-ionic-framework/

下载源码

通过命令行克隆项目:

git clone https://github.com/shprink/ionic-native-transitions.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 开发教程 ionic native transitions https://www.zuozi.net/31849.html

angular2 features
上一篇: angular2 features
shibboleth fastcgi
下一篇: shibboleth fastcgi
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务