2016-01-28 30 views
0

我有一個應用程序創建與Sencha觸摸,在應用程序的標題我有一個分段按鈕與三個不同的選項,當我改變視圖和我與此代碼工作:改變方向取決於你在哪裏進入Sencha觸摸應用程序

this.getEditorGeneral().animateActiveItem(0, {type:'slide', direction: 'right'}); 

(I改變號在分段按鈕的每個按鈕,這個例子僅僅是用於第一選擇)

問題是如何取決於如果我從改變定義動畫例如,第二個選項的第三個選項,第二個選項,第三個選項,我的想法是改變方向..

預先感謝您。

回答

0

我想你可以聽activeitemchange事件,它的處理函數需要參數newValue和Oldvalue - function(this, newValue, oldValue, eOpts) {}

埃姆,林不知道你的應用程序的結構,但想法是,你必須李斯特爲segmentedbutton事件activeitemchange(在控制器,使用的.on()或任何其他你喜歡的方式),並做一些事情,如:

myButton.on(
    'activeitemchange', 
    function(segmentedbutton, newValue, oldValue) { 
     // from second button to third, idk you actual button values so its just 2 and 3 
     if(newValue === 3 && oldValue === 2) { 
      this.getEditorGeneral().animateActiveItem(0, {type:'slide', direction: 'right'}); 
     // and vice versa 
     } else if(newValue === 2 && oldValue === 3) { 
      this.getEditorGeneral().animateActiveItem(0, {type:'slide', direction: 'left'}); 
     } 
    }, 
    // make sure that you pass proper scope so you can use getEditorGeneral() 
    this 
); 
+0

能不能請你應用到我的代碼的例子嗎? – inane

+0

增加了一個例子來說明我的意思,對不起,如果我錯誤地理解了觸摸特定部分中的問題,我實際上是ExtJS開發人員,而不是觸摸。 –

+0

我想myButton會是我分段按鈕的引用,對吧? – inane

0

嘗試設置不同的對象動畫,也許您可​​以嘗試在設置動畫之前使用開關盒設置方向字符串。

var direction='yourDirection', 
anim={type:'slide', direction: direction}; 
this.getEditorGeneral().animateActiveItem(0, anim); 

也許我無法理解你的要求