日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OS動畫

動畫分為靜態(tài)動畫和連續(xù)動畫。

靜態(tài)動畫

靜態(tài)動畫的核心是 transform 樣式,主要可以實現(xiàn)以下三種變換類型,一次樣式設(shè)置只能實現(xiàn)一種類型變換。

  • translate:沿水平或垂直方向?qū)⒅付ńM件移動所需距離。
  • scale:橫向或縱向?qū)⒅付ńM件縮小或放大到所需比例。
  • rotate:將指定組件沿橫軸或縱軸或中心點旋轉(zhuǎn)指定的角度。

靜態(tài)動畫只有開始狀態(tài)和結(jié)束狀態(tài),沒有中間狀態(tài),如果需要設(shè)置中間的過渡狀態(tài)和轉(zhuǎn)換效果,需要使用連續(xù)動畫實現(xiàn)。具體的使用示例如下,更多信息請參考組件。


hello hello hello

/* xxx.css */
.container {
  flex-direction: column;
  align-items: center;
}
.translate {
  height: 300px;
  width: 400px;
  font-size: 100px;
  background-color: #008000;
  transform: translate(300px);
}
.rotate {
  height: 300px;
  width: 400px;
  font-size: 100px;
  background-color: #008000;
  transform-origin: 200px 100px;
  transform: rotateX(45deg);
}
.scale {
  height: 300px;
  width: 400px;
  font-size: 100px;
  background-color: #008000;
  transform: scaleX(1.5);
}

圖1 靜態(tài)動畫效果圖

連續(xù)動畫

連續(xù)動畫的核心是 animation 樣式,它定義了動畫的開始狀態(tài)、結(jié)束狀態(tài)以及時間和速度的變化曲線。通過 animation 樣式可以實現(xiàn)的效果有:

  • animation-name:設(shè)置動畫執(zhí)行后應(yīng)用到組件上的背景顏色、透明度、寬高和變換類型。
  • animation-delayanimation-duration:分別設(shè)置動畫執(zhí)行后元素延遲和持續(xù)的時間。
  • animation-timing-function:描述動畫執(zhí)行的速度曲線,使動畫更加平滑。
  • animation-iteration-count:定義動畫播放的次數(shù)。
  • animation-fill-mode:指定動畫執(zhí)行結(jié)束后是否恢復(fù)初始狀態(tài)。

animation 樣式需要在 css 文件中先定義 keyframe,在 keyframe 中設(shè)置動畫的過渡效果,并通過一個樣式類型在 hml 文件中調(diào)用。animation-name 的使用示例如下:


animation-name
color
opacity

/* xxx.css */
.item-container {
  margin-bottom: 50px;
  margin-right: 60px;
  margin-left: 60px;
  flex-direction: column;
  align-items: flex-start;
}
.group {
  margin-bottom: 150px;
  flex-direction: column;
  align-items: flex-start;
}
.header {
  margin-bottom: 20px;
}
.item {
  background-color: #f76160;
}
.txt {
  text-align: center;
  width: 200px;
  height: 100px;
}
.button {
  width: 200px;
  font-size: 30px;
  color: #ffffff;
  background-color: #09ba07;
}
.color {
  animation-name: Color;
  animation-duration: 8000ms;
}
.opacity {
  animation-name: Opacity;
  animation-duration: 8000ms;
}
@keyframes Color {
  from {
    background-color: #f76160;
  }
  to {
    background-color: #09ba07;
  }
}
@keyframes Opacity {
  from {
    opacity: 0.9;
  }
  to {
    opacity: 0.1;
  }
}

// xxx.js
export default {
  data: {
    colorParam: '',
    opacityParam: '',
  },
  showAnimation: function () {
    this.colorParam = '';
    this.opacityParam = '';
    this.colorParam = 'color';
    this.opacityParam = 'opacity';
  },
}

圖2 連續(xù)動畫效果圖


文章標題:創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OS動畫
本文路徑:http://www.dlmjj.cn/article/cdhsgge.html