Sencha touch 为什么不是';t在Sencha Touch中设置动画的animateActiveItem函数
我的应用程序类中有以下代码:Sencha touch 为什么不是';t在Sencha Touch中设置动画的animateActiveItem函数,sencha-touch,sencha-touch-2,Sencha Touch,Sencha Touch 2,我的应用程序类中有以下代码: switchMainView: function (newView, config) { if (this.currentView != false) { Ext.Viewport.remove(this.currentView); } this.currentView = Ext.create(newView, config); Ext.Viewport.a
switchMainView: function (newView, config) {
if (this.currentView != false) {
Ext.Viewport.remove(this.currentView);
}
this.currentView = Ext.create(newView, config);
Ext.Viewport.animateActiveItem(this.currentView, { type: 'slide', direction: 'right' })
},
可以从任何控制器调用。但是,它不会显示动画。有什么问题吗?这是因为“This.currentView”视图还不是视口的一部分。在animateActiveItem行之前使用此行:
Ext.Viewport.add(this.currentView);
这应该会让它起作用。根据sencha guys的说法: AnimateActivItem(活动项,动画)将 使用指定的动画为提供的activeItem设置动画目前这仅适用于卡片布局。对于单个卡开关,此传递的动画将覆盖容器上的任何默认动画。动画完成后将被销毁
viewport: {
layout: {
type: 'card'
}
}
在app.js中添加上述代码不起作用,我注释掉了动画行,一旦调用add(),它就会出现在视图中…是的,我同意这一点,使用卡片布局可以执行动画。我想添加到这一点,因为这部分是由于我不理解。视口仅在存在要从中设置动画和要从中设置动画的对象时才设置动画。如果只有一张卡,即我先移除第一张卡,然后再添加一张新卡,它将无法工作,因为它将从0张卡转换为1张卡。