我还是js的新手,我正在尝试将bonsai.js放入骨干应用程序中。
我在这里关注此指南:https://github.com/iamdustan/bonsai-demos,并尝试将动画分成一个标题为hero-animation.js
的单独文件中的“将事情分开”,但我得到了Uncaught TypeError: Illegal constructor
hero-animation.js
这在我的Backbone路由器中调用,并且工作正常......
homeAnimation: function() {
bonsai.run(document.getElementById('heroContent'), {
url: 'hero-animation.js',
width: 500,
height: 400
});
}
以下是我在hero-animation.js中的内容,它导致第1行出错:
var rect = new Rect(0, 0, 200, 200);
rect
.fill('random')
.addTo(stage)
.attr({
x: stage.width - rect.attr('width'),
y: stage.width - rect.attr('height')
})
.animate('0.5s', {
x: 0,
y: 0
});