2012-07-17 92 views
1

我有一个容器的头部,内容(旋转木马)和页脚。容器本身是可滚动的(垂直)以能够向下滚动到页脚。旋转木马可以水平滑动以改变活动项目。我想锁定它做的只有两件事:防止可滚动容器(Sencha 2)内的传送带滚动?

  • 如果开始垂直移动,只有滚动集装箱
  • 如果开始水平移动,只有滚动旋转木马

如果你现在抢旋转木马您可以同时滚动两种方式。示例代码:

Ext.define('MyApp.view.MyContainer', { 
    extend: 'Ext.Container', 

    config: { 
     scrollable: true, 
     items: [ 
      { 
       xtype: 'container', 
       items: [ 
        { 
         xtype: 'label', 
         html: 'abc' 
        } 
       ] 
      }, 
      { 
       xtype: 'carousel', 
       height: 200, 
       scrollable: false, 
       items: [ 
        { 
         xtype: 'label', 
         html: 'x' 
        }, 
        { 
         xtype: 'label', 
         html: 'y<br/>y<br/>y<br/>y<br/>y<br/>y<br/>y<br/>y' 
        } 
       ] 
      }, 
      { 
       xtype: 'container', 
       items: [ 
        { 
         xtype: 'label', 
         html: 'def' 
        } 
       ] 
      } 
     ] 
    } 

}); 

使用煎茶触摸2.

回答

1

如果开始水平移动,只有滚动旋转木马

只需添加到您的容器的配置:

config: { 
    scrollable: { 
    direction: 'vertical', 
    directionLock:true 
    } 
} 

垂直滚动时我还没有想出如何锁定旋转木马。如果我知道,我会通知你。

1

试试这个。它对我来说工作得很好。

Ext.define('MyApp.view.MyContainer', { 
    extend: 'Ext.Container', 

    config: { 
     scrollable: { 
      direction: 'vertical' 
     }, 
     items: [ 
      { 
       xtype: 'container', 
       items: [ 
        { 
         xtype: 'label', 
         html: 'abc' 
        } 
       ] 
      }, 
      { 
       xtype: 'carousel', 
       height: 200, 
       direction: 'horizontal', 
       directionLock: true, 
       items: [ 
        { 
         xtype: 'label', 
         html: 'x' 
        }, 
        { 
         xtype: 'label', 
         html: 'y<br/>y<br/>y<br/>y<br/>y<br/>y<br/>y<br/>y' 
        } 
       ] 
      }, 
      { 
       xtype: 'container', 
       items: [ 
        { 
         xtype: 'label', 
         html: 'def' 
        } 
       ] 
      } 
     ] 
    } 
}); 
2

您可能需要阻止在滚动。这将有助于防止对垂直滚动和旋转木马项目变更,在同一time.Try里面发生的滚动容器的验证码。

scrollable: { 
      directionLock: true, 
      direction: 'vertical', 
      momentumEasing: { 
      momentum: { 
       acceleration: 30, 
       friction: 0.5 
      }, 
      bounce: { 
       acceleration: 0.0001, 
       springTension: 0.9999, 
      }, 
      minVelocity: 3 
      }, 
      outOfBoundRestrictFactor: 0 
     },