【问题标题】:How to scroll vertically in sencha touch?如何在煎茶触摸中垂直滚动?
【发布时间】:2013-06-17 15:30:37
【问题描述】:

我正在使用 sencha 触摸轮播,我在其中使用水平滑动。哪个完美。 但在其中我正在使用我想垂直滚动的面板(将每一页滚动到底部)。怎么做?我在每个面板中给出了 scroll:'vertical' 如下:

var myFirstPage = Ext.Panel({
      id:'tableId',
          iconCls:'myToolBar',
          style:'overflow:auto;' ,
          scroll:'vertical',
          items:.........});
Ext.setup( {
    onReady: function() {
      myCarouselId = new Ext.Carousel({
        fullscreen: true,
        id:'myCar',

        items : [ myFirstPage]...............});

但我无法将面板滚动到底部。哪里出错了?

Sencha touch vertical scroll content in a horizontal carousel 。根据这个stackoverflow答案,我们可以在水平轮播中垂直滚动子内容,和我一样的问题。但我在这里做同样的事情,我无法滚动。 我的子面板包含 vbox 和 hbox 布局。

有人可以回答我的问题吗?

【问题讨论】:

    标签: javascript sencha-touch


    【解决方案1】:

    试试这个,它对我有用,我从sench forum得到它

    在面板中设置可滚动配置

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

    示例

    var myFirstPage = Ext.Panel({
              id:'tableId',
              iconCls:'myToolBar',
              scrollable : {
                direction     : 'vertical',
                directionLock : true
             },
            items:.........});
    
    Ext.setup( {
        onReady: function() {
          myCarouselId = new Ext.Carousel({
            fullscreen: true,
            id:'myCar',
            items : [ myFirstPage]...............});
    

    看到这个fiddle

    【讨论】:

    • @SSS 不适合我,我测试了我在答案中发布的小提琴
    • 我只使用了一个带有 vbox 布局的面板(它是默认的.. 无需指定).. 你可以用你的代码创建小提琴(尽可能简单)或者只是用面板项目代码更新你的问题
    • @SSS 为什么要在工具栏中添加工具栏?你的面板代码充满了工具栏?
    • 我不认为你能做到这一点,你想在那个面板中实现什么?
    • 我已将工具栏更改为容器并检查了它。它不起作用。我认为 hbox 布局滚动不起作用
    【解决方案2】:

    编辑:如果您希望面板内的“hbox”可用性,则需要使其宽度适合容器内。
    如果它需要创建自己的滚动条,它不会这样做。

    您需要以不同的方式定义滚动:

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

    像这样:

        var carousel = Ext.create('Ext.Carousel', {
    fullscreen: true,
    items : [ 
        {  xtype: 'panel',     
           scrollable: {
             direction: 'vertical',
             directionLock: true
           },
           html: 'This panel is scrollable!',
           items: [{
                    xtype: 'textfield',
                    name : 'first',
                    label: 'First'
                },
                {
                    xtype: 'textfield',
                    name : 'second',
                    label: 'Second'
                },{
                    xtype: 'textfield',
                    name : 'third',
                    label: 'Third'
                },{
                    xtype: 'textfield',
                    name : 'first1',
                    label: 'First1'
                },
                {
                    xtype: 'textfield',
                    name : 'second1',
                    label: 'Second1'
                },{
                    xtype: 'textfield',
                    name : 'third1',
                    label: 'Third1'
                },{
                    xtype: 'textfield',
                    name : 'first12',
                    label: 'First12'
                },
                   { xtype: 'panel',
                    layout: 'hbox',
                    width: 200,
                    items: [{
                        xtype: 'textfield',
                        name : 'first-box',
                        label: 'First-box'
                    },
                    {
                        xtype: 'textfield',
                        name : 'second-box',
                        label: 'Second-box'
                    },{
                        xtype: 'textfield',
                        name : 'third-box',
                        label: 'Third-box'
                    }]
               }, {
                    xtype: 'textfield',
                    name : 'second12',
                    label: 'Second12'
                },{
                    xtype: 'textfield',
                    name : 'third12',
                    label: 'Third12'
                }]
        }, {
           xtype: 'panel',
           scroll:'vertical',  // will not work
           html: 'This panel is not scrollable!',
        }]
    });
    

    您可以在sencha docs的任何实时预览中尝试此操作
    希望这会有所帮助

    【讨论】:

    • 是的,它会滚动,但一旦我离开手指,它就会回到原来的位置
    • @SSS 我编辑了我的答案以符合“hbox”的需求。如果超出设备范围,它会很好地工作。
    猜你喜欢
    • 1970-01-01
    • 2012-11-04
    • 2012-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-25
    • 1970-01-01
    相关资源
    最近更新 更多