連續貝塞爾動畫,不繼承變化時的緩動功能 (Continuous bezier animation without inheriting easing-function on change)


問題描述

連續貝塞爾動畫,不繼承變化時的緩動功能 (Continuous bezier animation without inheriting easing‑function on change)

我有這個動畫,它目前只是在開始時很快,但是當它達到 85% ‑ 95% 時,三次貝塞爾曲線應該持續緩慢,而不是再次從點 0 開始並創建另一個快速啟動動作. 有沒有辦法為每個動畫狀態變化添加多個三次貝塞爾曲線,或者讓緩動函數在狀態之間連續?


.animate‑winner {
  animation: rollWinnerBait 9s cubic‑bezier(0,.9,.76,.99) forwards normal 1
}

@keyframes rollWinnerBait { 
  0% {
    transform: translateX(4988px)
  }

  85% {
    transform: translateX(‑80px)
  }

  95% {
    transform: translateX(11px)
  }

  98% {
    transform: translateX(‑9px)
  }

  100% {
    transform: translateX(0px)
  }
}


參考解法

方法 1:

Update the timing function inside the animation:

.animate‑winner {
  animation: rollWinnerBait 5s cubic‑bezier(0, .9, .76, .99) forwards;
  width:100px;
  height:100px;
  margin:5px;
  background:red;
}
.animate‑winner.new {
  animation: rollWinnerBait‑new 5s cubic‑bezier(0, .9, .76, .99) forwards;
}

@keyframes rollWinnerBait {
  0% {
    transform: translateX(4988px)
  }
  85% {
    transform: translateX(‑80px);
  }
  95% {
    transform: translateX(11px)
  }
  98% {
    transform: translateX(‑9px)
  }
  100% {
    transform: translateX(0px);
  }
}

@keyframes rollWinnerBait‑new {
  0% {
    transform: translateX(4988px)
  }
  85% {
    transform: translateX(‑80px);
    animation‑timing‑function:linear;
  }
  95% {
    transform: translateX(11px)
  }
  98% {
    transform: translateX(‑9px)
  }
  100% {
    transform: translateX(0px);
    animation‑timing‑function:linear;
  }
}
<div class="animate‑winner"></div>

<div class="animate‑winner new"></div>

(by ShimshoTemani Afif)

參考文件

  1. Continuous bezier animation without inheriting easing‑function on change (CC BY‑SA 2.5/3.0/4.0)

#animation #css #cubic-bezier #css-animations






相關問題

Iphone app PNG 序列動畫 - 如何在不崩潰的情況下以最佳方式使用 OPENgle (Iphone app PNG sequence animation - How to use OPENgle optimally without crashing)

jquery切換幻燈片和切換旋轉動畫 (jquery toggle slide and toggle rotation animate)

如何在三次貝塞爾方法上禁用 css3 過渡鼠標離開效果? (How to disable css3 transition mouseleave effect on cubic-bezier method?)

Android:故事書(動畫、聲音、圖片) (Android: Storybooks (animation, sounds, pictures))

JQuery 動畫凌亂 (JQuery Animations Messy)

拉斐爾對角變換對象和無限setIntervals (Raphael transform object diagonally and infinite setIntervals)

使用 mouseover 和 mouseout 時避免生澀的動畫 (Avoiding jerky animation when using mouseover and mouseout)

在 C 中復制 Spinrite 動畫效果 (Replicating Spinrite Animation Effect in C)

將樣式作為參數傳遞給 jquery animate (passing style as argument to jquery animate)

如何設置 UIButton 的圖像並隨後將其刪除(動畫) (How to setImage of a UIButton and subsequently remove it (animation))

單擊消息後的 MessageKit 動畫 (MessageKit animation after click on message)

連續貝塞爾動畫,不繼承變化時的緩動功能 (Continuous bezier animation without inheriting easing-function on change)







留言討論