欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序?qū)崿F(xiàn)自定義加載圖標(biāo)功能

 更新時(shí)間:2018年07月19日 09:27:04   作者:Rattenking  
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)自定義加載圖標(biāo)功能,非常不錯(cuò)具有一定的參考借鑒價(jià)值,需要的朋友參考下吧

效果圖

這里寫圖片描述

實(shí)現(xiàn)思路

1.首先通過HTML+CSS實(shí)現(xiàn)加載動(dòng)畫的靜態(tài)效果;

2.根據(jù)需求給每個(gè)動(dòng)畫設(shè)計(jì)不同的動(dòng)畫效果。

例如第一個(gè)加載圖標(biāo)的靜態(tài)繪制

1、首先確定動(dòng)畫的盒子寬高;

2、設(shè)置盒子中每一個(gè)長(zhǎng)方形的寬高以及定位(注意:此處需要將長(zhǎng)方形的旋轉(zhuǎn)中心點(diǎn)移動(dòng)到長(zhǎng)方形的右側(cè)邊終點(diǎn),方便后期以該點(diǎn)旋轉(zhuǎn)。);

3、通過長(zhǎng)方形盒子的偽元素,設(shè)置顯示的長(zhǎng)方形背景和寬高,同時(shí)進(jìn)行定位。

4、由于在第二步的時(shí)候,已經(jīng)將旋轉(zhuǎn)中心移動(dòng),此處我們直接對(duì)每一個(gè)盒子中長(zhǎng)方形進(jìn)行旋轉(zhuǎn)(注意:旋轉(zhuǎn)角度 = 360 / 盒子中長(zhǎng)方形個(gè)數(shù))。

.circle-line{
  width: 100px;
  height: 100px;
  display: inline-block;
  position: relative;
}
.circle-line text{
  display: block;
  width: 50%;
  height: 5px;
  opacity: .7;
  position: absolute;
  top: calc(50% - 2.5px);
  left: 0px;
  transform-origin: center right; 
}
.circle-line text::before{
  content: '';
  display: block;
  width: 15px;
  height: 5px;
  position: absolute;
  top: 0;
  right: 10px;
  background-color: blue;
}
.circle-line text:nth-child(1){
  transform: rotate(0deg);
}
.circle-line text:nth-child(2){
  transform: rotate(45deg);
}
.circle-line text:nth-child(3){
  transform: rotate(90deg);
}
.circle-line text:nth-child(4){
  transform: rotate(135deg);
}
.circle-line text:nth-child(5){
  transform: rotate(180deg);
}
.circle-line text:nth-child(6){
  transform: rotate(225deg);
}
.circle-line text:nth-child(7){
  transform: rotate(270deg);
}
.circle-line text:nth-child(8){
  transform: rotate(315deg);
}

動(dòng)畫制作

觀察發(fā)現(xiàn)動(dòng)畫只是針對(duì)每個(gè)長(zhǎng)方形的透明度進(jìn)行改變,所以動(dòng)畫采用從0.05到0.9的透明度循環(huán)改變。

@keyframes circle {
  0%{
    opacity: 0.05;
  }
  100%{
    opacity: 0.9;
  }
}

進(jìn)行動(dòng)畫綁定

.circle-line text{
  animation: circle 1.5s linear infinite; 
}

動(dòng)畫綁定完成,發(fā)現(xiàn)所有的整個(gè)圖標(biāo)一起顯示消失,那么也就是缺少了對(duì)單個(gè)個(gè)體的動(dòng)畫處理,延遲動(dòng)畫時(shí)間,使其依次漸變。

單個(gè)動(dòng)畫處理

.circle-line text:nth-child(1){
  animation-delay: 0.2s;
}
.circle-line text:nth-child(2){
  animation-delay: 0.4s;
}
.circle-line text:nth-child(3){
  animation-delay: 0.6s;
}
.circle-line text:nth-child(4){
  animation-delay: 0.8s;
}
.circle-line text:nth-child(5){
  animation-delay: 1s;
}
.circle-line text:nth-child(6){
  animation-delay: 1.2s;
}
.circle-line text:nth-child(7){
  animation-delay: 1.4s;
}
.circle-line text:nth-child(8){
  animation-delay: 1.6s;
}

注意:?jiǎn)蝹€(gè)動(dòng)畫延遲的時(shí)間必須超過動(dòng)畫執(zhí)行的總時(shí)間,防止一個(gè)動(dòng)畫執(zhí)行完成后的卡頓。

總結(jié)

以上所述是小編給大家介紹的微信小程序?qū)崿F(xiàn)自定義加載圖標(biāo)功能,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論