您好,登錄后才能下訂單哦!
小編給大家分享一下基于Angular.js如何實現觸摸滑動動畫,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
先上圖:
這個主要用到是angular-touch.js中封裝好的ng-swipe-left,ng-swipe-right,向左或向右的觸摸事件。結合css3的transition實現的動畫。ng-class為切換寫好的動畫的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如何實現觸摸滑動動畫”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。