2016-01-28 34 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); 

也许我无法理解你的要求