者:semlinker
轉發鏈接:https://mp.weixin.qq.com/s/p0U8sVLtWd78CLc8kM22FQ
titanic是在Github上開源的一組免費的動畫圖標,可以將其簡單的運用到網頁中,而且代碼及其簡單,但是動畫效果卻很不錯,動畫圖標和靜態圖標的不同之處在于它可以讓你的網頁更加富有活力,讓產品更加具備視覺吸引力,一起來看看!
https://github.com/icons8/titanic
安裝使用及其簡單,可以通過CDN或npm安裝它:
npm install titanic-icons --save
將代碼引入你網頁的head中后:
<script src="/dist/js/titanic.min.js"></script> <script src="/bodymovin/4.5.9/bodymovin.min.js"></script>
在body中初始化:
<script> var titanic = new Titanic(); </script>
這樣,你就可以在HTML中使用任意位置以下標簽添加圖標:
<div class='titanic titanic-chat'></div>
chat可以是以下任一一種:
1、titanic.isInitialized()
判斷是否初始化成功
2、titanic.items
獲取titanic集合
3、titanic.items[index].on(), titanic.items[index].off(), titanic.items[index].play()
按索引播放titanic的動畫
4、titanic.on(token), titanic.off(token), titanic.play(token)
通過名稱播放泰坦尼克號物品的動畫
5、以下是一個完成的示例:
<head> <!--Inserting the scripts once for the whole page--> <script src="/dist/js/titanic.min.js"></script> <script src="/libs/bodymovin/4.5.9/bodymovin.min.js"></script> </head> <body> <!--Inserting an icon--> <div class='titanic titanic-checkbox'></div> <!--Initializing--> <script> var titanic = new Titanic({ hover: true, // auto animated on hover (default true) click: true // auto animated on click/tap (default false) }); </script> <!--Clicking turns this icon on--> <button onclick="titanic.on(getElementById('checkbox').value)">On</button> </body>
通過截圖大致了解,可以直接訪問官方網站查看動畫效果:
每個人都喜歡個性鮮明的頁面。通過200個動畫圖標包,使Web和移動用戶界面更具視覺吸引力。
titanic是一組豐富的動畫圖標,可以讓你的網頁極具視覺吸引力,是設計師和前端工程師的不二之選,感興趣的可以嘗試!
PS:你可以直接從官網或者Github獲取,當然也可以私信本頭條號關鍵字:“icons”,Enjoy it!
一個輕量級的粒子庫,目前版本2.0.0,目前github star 19K+,MIT協議,官網截圖如下:
1, npm
npm install particles.js
2, 官網下載particles.js到本地,html script 指向它。
particles.json
{ "particles": { "number": { "value": 80, "density": { "enable": true, "value_area": 800 } }, "color": { "value": "#ffffff" }, "shape": { "type": "circle", "stroke": { "width": 0, "color": "#000000" }, "polygon": { "nb_sides": 5 }, "image": { "src": "img/github.svg", "width": 100, "height": 100 } }, "opacity": { "value": 0.5, "random": false, "anim": { "enable": false, "speed": 1, "opacity_min": 0.1, "sync": false } }, "size": { "value": 10, "random": true, "anim": { "enable": false, "speed": 80, "size_min": 0.1, "sync": false } }, "line_linked": { "enable": true, "distance": 300, "color": "#ffffff", "opacity": 0.4, "width": 2 }, "move": { "enable": true, "speed": 12, "direction": "none", "random": false, "straight": false, "out_mode": "out", "bounce": false, "attract": { "enable": false, "rotateX": 600, "rotateY": 1200 } } }, "interactivity": { "detect_on": "canvas", "events": { "onhover": { "enable": false, "mode": "repulse" }, "onclick": { "enable": true, "mode": "push" }, "resize": true }, "modes": { "grab": { "distance": 800, "line_linked": { "opacity": 1 } }, "bubble": { "distance": 800, "size": 80, "duration": 2, "opacity": 0.8, "speed": 3 }, "repulse": { "distance": 400, "duration": 0.4 }, "push": { "particles_nb": 4 }, "remove": { "particles_nb": 2 } } }, "retina_detect": true }
particles.json 各個屬性具體作用,可以去官網查閱,可以根據不同的particles.json配置各種酷炫的粒子特效。
app.js
/* particlesJS.load(@dom-id, @path-json, @callback (optional)); */ particlesJS.load('particles-js', 'assets/particles.json', function() { console.log('callback - particles-js config loaded'); });
index.html
*請認真填寫需求信息,我們會在24小時內與您取得聯系。