使用 Element 的 animate() 方法来给 UI 元件设置 CSS Animation 动画。
Element
animate()
animate(keyframes, options);
function controlAnimation(ele: MainThread.Element) { 'main thread' ele.animate( [ { // from opacity: 0, color: '#fff', }, { // to opacity: 1, color: '#000', }, ], 2000, ); }
function controlAnimation(ele: MainThread.Element) { 'main thread' ele.animate( [ { // from opacity: 0, color: '#fff', 'animation-timing-function': 'linear', }, { // to opacity: 1, color: '#000', 'animation-timing-function': 'ease-in', }, ], 2000, ); }
包含一个或多个属性的对象: