2017-05-26 46 views
1

假設我想使用類似JQuery UI的東西來寫一些動畫時,元素被添加或從DOM中刪除。我在this article中看到,我可以使用動畫製作器界面來編寫我自己的動畫,使用輸入請假函數。這篇文章使用view-slot.js的例子來展示如何使用這個接口。我甚至可以看到這種依賴被注入到這裏,像這樣如何在Aurelia中實現我自己的動畫庫?

import {Animator} from './animator'; 
... 
constructor(anchor: Node, anchorIsContainer: boolean, animator?: Animator = Animator.instance) { 

我該如何在這裏提供我自己的Animator接口實現?我使用另一個JavaScript動畫庫Greensock aurelia plugin作爲示例,說明如何使用它自己的版本animator.js以及寫入其中的Greensock動畫。我希望能找到一些能夠爲view-slot構造函數提供animator接口的自定義實現的東西,但卻是空的。

任何幫助表示讚賞。

回答

1

找到它。您需要在駐留在Aurelia的DI容器中的模板引擎上運行configureAnimator。下面的例子來自animator-css,它是animator接口的一個實現。這段代碼在啓動過程中作爲插件運行。

export function configure(config: Object, callback?:(animator:CssAnimator) => void): void { 
    let animator = config.container.get(CssAnimator); 
    config.container.get(TemplatingEngine).configureAnimator(animator); 
    if (typeof callback === 'function') { callback(animator); } 
} 

https://github.com/aurelia/animator-css/blob/master/src/index.js