基于Angular.js實(shí)現(xiàn)的觸摸滑動(dòng)動(dòng)畫實(shí)例代碼
先上圖:
這個(gè)主要用到是angular-touch.js中封裝好的ng-swipe-left,ng-swipe-right,向左或向右的觸摸事件。結(jié)合css3的transition實(shí)現(xiàn)的動(dòng)畫。ng-class為切換寫好的動(dòng)畫的className.
<!DOCTYPE HTML> <html ng-app="myapp"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> <title>Angular2</title> <script type="text/javascript" charset="utf-8" src="angular.min.js"></script> <script type="text/javascript" charset="utf-8" src="angular-touch.min.js"></script> <style type="text/css"> *{margin:0px;padding:0px;} .box{position:relative;left:0px;margin:10px 0px;width:100%;height:100px;background:red;transition:all .5s;;} .swipeleft{left:-100%;} </style> <script type="text/javascript" charset="utf-8"> angular.module("myapp",["ngTouch"]).controller("Controller",[function(){ var self = this; self.swipeLeft = function(){ return (self.className = "swipeleft"); } }]); </script> </head> <body> <ul> <li ng-controller="Controller as con" class="box box1" ng-swipe-left="con.swipeLeft()" ng-class="con.className"></li> <li ng-controller="Controller as con" class="box box2" ng-swipe-left="con.swipeLeft()" ng-class="con.className"></li> <li ng-controller="Controller as con" class="box box3" ng-swipe-left="con.swipeLeft()" ng-class="con.className"></li> <li ng-controller="Controller as con" class="box box4" ng-swipe-left="con.swipeLeft()" ng-class="con.className"></li> </ul> </body> </html>
以上所述是小編給大家介紹的基于Angular.js實(shí)現(xiàn)的觸摸滑動(dòng)動(dòng)畫實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的!
- Angular4.0動(dòng)畫操作實(shí)例詳解
- Angular4如何自定義首屏的加載動(dòng)畫詳解
- Angular2搜索和重置按鈕過場(chǎng)動(dòng)畫
- 給angular加上動(dòng)畫效遇到的問題總結(jié)
- 利用CSS3在Angular中實(shí)現(xiàn)動(dòng)畫
- AngularJS中實(shí)現(xiàn)顯示或隱藏動(dòng)畫效果的方式總結(jié)
- 使用ngView配合AngularJS應(yīng)用實(shí)現(xiàn)動(dòng)畫效果的方法
- 在AngularJS應(yīng)用中實(shí)現(xiàn)一些動(dòng)畫效果的代碼
- 詳解Angular路由動(dòng)畫及高階動(dòng)畫函數(shù)
相關(guān)文章
深入探究AngularJs之$scope對(duì)象(作用域)
本篇文章主要介紹了深入探究AngularJs之$scope對(duì)象(作用域),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07Angular實(shí)現(xiàn)表單驗(yàn)證功能
這篇文章主要為大家詳細(xì)介紹了Angular實(shí)現(xiàn)表單驗(yàn)證功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-11-11淺談AngularJS中$http服務(wù)的簡(jiǎn)單用法
這篇文章主要介紹了淺談AngularJS中$http服務(wù)的簡(jiǎn)單用法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-05-05AngularJS 模型詳細(xì)介紹及實(shí)例代碼
本文主要介紹 AngularJS模型,這里詳細(xì)介紹了AngularJS 模型中的知識(shí)點(diǎn),并提供實(shí)例代碼,有需要的小伙伴可以參考下2016-07-07Angular組件庫(kù)ng-zorro-antd實(shí)現(xiàn)radio單選框選擇
這篇文章主要為大家介紹了Angular組件庫(kù)ng-zorro-antd實(shí)現(xiàn)radio單選框取消選擇實(shí)現(xiàn)問題解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-05-05