Sencha Touch中不会触发滚动条事件

问题描述 投票:3回答:1

我在数据视图中配置了滚动事件,但不会触发。其余的可滚动配置都可以,只是似乎没有考虑监听器conf。有任何线索吗?

{   itemId:'names',
    xtype:'dataview',
    disableSelection:true,
    scrollable:{
        direction:'vertical',
        listeners:{
            scroll:function(){
                console.log('[scrollable][on scroll]');
            },
            scrollend:function( scroller, x, y, eOpts ){
                console.log('[scrollable][on scrollend]x='+x+', y='+y);
            }
        }
    },
    store:{
            fields:['name'],
            data:[{name:'Cherif'}]
    },

    itemTpl:'{name}'
}
javascript extjs sencha-touch sencha-touch-2 dom-events
1个回答
5
投票

编辑:这次实际上尝试过建议的修复方法

您需要将listeners配置放在scroller中作为demonstrated in this jsFiddle

{
    xtype:'dataview',
    fullscreen: true,
    scrollable: {
        direction:'vertical',
        scroller: {
            listeners:{
                scroll:function(){
                    console.log('[scrollable][on scroll]');
                },
                scrollend:function( scroller, x, y, eOpts ){
                    console.log('[scrollable][on scrollend]x='+x+', y='+y);
                }
            }
        }
    },
    store: {
        fields: ['name', 'age'],
        data: [
            {name: 'Jamie',  age: 100},
            {name: 'Rob',   age: 21},
            {name: 'Tommy', age: 24},
            {name: 'Jacky', age: 24},
            {name: 'Ed',   age: 26}
        ]
    },

    itemTpl: '<div>{name} is {age} years old</div>'
}
© www.soinside.com 2019 - 2024. All rights reserved.