講解使用SVG製作loading加載動畫的方法

今天和大家分享一個以SVG圖像爲主的loading加載動畫,現在移動端網頁使用比較多,若還用GIF做loading圖片的話,可能會影響圖像的質量,所以使用SVG是一個不錯的方式。

講解使用SVG製作loading加載動畫的方法

這次展示的`代碼由 Aurer 編寫,前端人員只需要直接複製想要的SVG代碼就能直接使用,而且可以改變顏色。當然,對於好學的同學,也可以研究下這個代碼的編寫原理。

下面我們來看一下具體的兩個加載相關的用法:

ionic 加載動作 $ionicLoading

$ionicLoading 是 ionic 默認的一個加載交互效果。裏面的內容也是可以在模板裏面修改。

使用實例:

HTML 代碼:

XML/HTML Code複製內容到剪貼板TheStooges{{}}

JavaScript 代碼

JavaScript Code複製內容到剪貼板 le(‘ionicApp‘,[‘ionic‘]) roller(‘AppCtrl‘,function($scope,$timeout,$ionicLoading){ //Setuptheloader $({ content:‘Loading‘, animation:‘fade-in‘, showBackdrop:true, maxWidth:200, showDelay:0 }); //Setatimeouttoclearloader,howeveryouwouldactuallycallthe$();methodwhenevereverythingisreadyorloaded. $timeout(function(){ $(); $ges=[{name:‘Moe‘},{name:‘Larry‘},{name:‘Curly‘}]; },2000); });

$ionicLoadingConfig

使用實例:

HTML 代碼

XML/HTML Code複製內容到剪貼板

CSS 代碼

CSS Code複製內容到剪貼板 body{ cursor:url(‘http://www.runob.com/try/demo_source/finger.png‘),auto; } p{ text-align:center; margin-bottom:40px!important; } nersvg{ width:19%!important; height:85px!important; }

JavaScript 代碼

JavaScript Code複製內容到剪貼板 le(‘ionicApp‘,[‘ionic‘]) roller(‘MyCtrl‘,function($scope){ });