2012-04-01 42 views
4

在煎茶觸摸2,我在我的控制器使用此代碼片段:煎茶觸摸2 setActiveItem動畫不工作

 this.control({ 
     '#test_button': {   
      tap: function() { 
       var root_c = Ext.getCmp("main_container"); 
       root_c.setActiveItem(
        1, {type:'slide', direction: 'left'} 
       ); 
      } 
     }   
    }); 

它工作得很好,但它切換隻有「默認方式」,而不是「滑辦法」。誰能幫忙,爲什麼?

由於提前, [R

+0

這個問題在這裏得到解決:http://www.sencha.com/forum/showthread.php?192411-setActiveItem-animation-doesnt-work 需要使用animateActiveItem而不是setActiveItem(只在ST2中) – RobbeR 2012-04-01 17:21:36

回答

2

正如其他人說,使用animateActiveItem。或者,您可以保留您的(單個參數)setActiveItem,並在顯示的特定視圖上設置showAnimation和hidAnimation。

說了這樣的話,如果您的展示物品嵌套了大量來回,這在我的經驗中是有問題的。

更新只是發現,有一個在st2.0.1例如,如果使用顯示/ hideAnimation,你不能真正銷燬已設置該屬性的對象明顯的時序錯誤。咬我很難。相關閱讀:http://www.sencha.com/forum/showthread.php?192847-Animating-panels-throws-Cannot-call-method-getPageBox-of-null

2

在煎茶觸摸2,爲您的需要選擇正確的方法是animateActiveItem

2
this.control({ 
    '#test_button': {   
     tap: function() { 
     var root_c = Ext.getCmp("main_container"); 
      root_c.animateActiveItem(1, {type:'slide', direction: 'left'}); 
     } 
    }   
    }); 

在煎茶觸摸2 setActiveItem只有一個參數:

setActiveItem(Object/Number activeItem) 

所以你必須使用:

animateActiveItem(Object/Number activeItem, Object/Ext.fx.layout.Card animation) 

更多信息:http://docs.sencha.com/touch/2-0/#!/api/Ext.Container-method-animateActiveItem