Sench Touch 监听滚动事件

由于dataview的分页插件中加载更多按钮会显示在上面,只能放弃使用分页插件,改成了滚动到底部自动刷新,下面这就是在网上找到的监听滚动事件:

1.这是在控制器里的:

config: {
    refs: {
        list: '...',
        ...
    },
    control: {
        list: {
            initialize: 'onListInit'
        },
        ...
    },
    ...
},
onListInit: function(thisCOMP) {
    var scroller = thisCOMP.getScrollable().getScroller();
    scroller.on('scrollstart', this.onNnListScrollStart, this);
    scroller.on('scrollend',   this.onNnListScrollEnd,   this);
},
onNnListScrollStart: function(scroller, x, y) {
    console.log('START SCROLL');
},

onNnListScrollEnd: function(scroller, x, y) {
    console.log('scroll x:'+x);
    console.log('scroll y:'+y);

    var bottom = scroller.maxPosition.y;
    var top    = scroller.minPosition.y;

    var isScrollUp   = scroller.dragDirection.y === -1;
    var isScrollDown = scroller.dragDirection.y === 1;

    if (bottom === y && isScrollDown) {
        console.log('BOTTOM');    
    }

    if (top === y && isScrollUp) {
        console.log('TOP');
    }

    console.log('END SCROLL');
},
...



来源:http://stackoverflow.com/questions/18762768/how-to-get-scroll-at-bottom-and-scroll-at-top-of-a-list-view-of-a-sencha-tou

2.这是在视图里的:

{
    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>'
}



来源:http://stackoverflow.com/questions/18871581/scroller-events-dont-fire-in-sencha-touch


转载于:https://my.oschina.net/geomen/blog/601246

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值