Morf.js 提供了一组 JavaScript 方法用于加速 CSS3 的各种转换效果,支持的方法都在上图中,无需编写 CSS3 代码。
示例代码:
// Get a reference to the element var elem = document.getElementById('elem'); var trans = Morf.transition(elem, { // New CSS state '-webkit-transform': 'translate3d(300px, 0, 0) rotate(90deg)', 'background-color': '#FF0000' }, { duration: '1500ms', timingFunction: 'bounce', callback: function (elem) { // You can optionally add a callback option for when the animation completes. } });