【问题标题】:Sencha Touch 2.3.1 list scroll freezingSencha Touch 2.3.1 列表滚动冻结
【发布时间】:2014-07-07 03:13:20
【问题描述】:

我正在使用 Sencha Touch 2.3.1 并使用这样定义的列表:

        {
            xtype: 'list',
            id: 'index_list',
            infinite: true,
            flex: 1,
            scrollToTopOnRefresh: false,
            disableSelection: true,
            store: 'store_index'
        }

List 的商店有超过 300 条记录,这就是为什么我将标志“infinite”设置为 true。

问题是当我在列表中快速上下滚动时,应用程序冻结并且我无法对 UI 执行任何其他操作。

也经过测试,将无限标志设置为 false 并不能解决此问题。

如果数据少于约 300 条记录,则无法重现

平台:iOS 6、7 (iPhone),而不是 iPad。

你有什么想法吗?

【问题讨论】:

  • 您是在一个请求或存储调用中获取/保存所有这 300 条记录吗?顺便说一句,请添加 itemtpl

标签: ios list touch infinite


【解决方案1】:

使用这个覆盖对我有用

Ext.define('InfiniteListScroll.override.TouchGesture', {
override: 'Ext.event.publisher.TouchGesture',

lastEventType: null,
changedTouchesId: null,
lastEventObject: null,

onEvent: function(e) {
    console.log('InfiniteListScroll.override.TouchGesture - onEvent');
    var type = e.type,
        lastEventType = this.lastEventType,
        touchList = [e];

    if ( type == 'touchstart' ) {
        if( this.changedTouchesId == null ) {
            this.changedTouchesId = e.changedTouches[0].identifier;
            this.lastEventObject = e;
        }
        else {
            console.log('changedTouchesId NOT null, touchEnd event wasnt fired for corresponding touchStart event.');
            this.onTouchEnd( this.lastEventObject );
        }
    }
    if (this.eventProcessors[type]) {
        this.eventProcessors[type].call(this, e);
        return;
    }
    if ('button' in e && e.button > 0) {
        return;
    }
    else {
        // Temporary fix for a recent Chrome bugs where events don't seem to bubble up to document
        // when the element is being animated with webkit-transition (2 mousedowns without any mouseup)
        if (type === 'mousedown' && lastEventType && lastEventType !== 'mouseup') {
            var fixedEvent = document.createEvent("MouseEvent");
                fixedEvent.initMouseEvent('mouseup', e.bubbles, e.cancelable,
                    document.defaultView, e.detail, e.screenX, e.screenY, e.clientX,
                    e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.metaKey,
                    e.button, e.relatedTarget);
            this.onEvent(fixedEvent);
        }
        if (type !== 'mousemove') {
            this.lastEventType = type;
        }
        e.identifier = 1;
        e.touches = (type !== 'mouseup') ? touchList : [];
        e.targetTouches = (type !== 'mouseup') ? touchList : [];
        e.changedTouches = touchList;
        this.eventProcessors[this.mouseToTouchMap[type]].call(this, e);
    }
},


onTouchEnd: function(e) {
    console.log('InfiniteListScroll.override.TouchGesture - onTouchEnd');
    if (!this.isStarted) {
        return;
    }
    if (this.lastMoveEvent) {
        this.onAnimationFrame();
    }
    var touchesMap = this.touchesMap,
        currentIdentifiers = this.currentIdentifiers,
        changedTouches = e.changedTouches,
        ln = changedTouches.length,
        identifier, i, touch;

    this.changedTouchesId = null;
    this.updateTouches(changedTouches);
    changedTouches = e.changedTouches;
    for (i = 0; i < ln; i++) {
        Ext.Array.remove(currentIdentifiers, changedTouches[i].identifier);
    }
    e = this.factoryEvent(e);
    for (i = 0; i < ln; i++) {
        identifier = changedTouches[i].identifier;
        touch = touchesMap[identifier];
        delete touchesMap[identifier];
        this.publish('touchend', touch.targets, e, {touch: touch});
    }
    this.invokeRecognizers('onTouchEnd', e);
    // Only one touch currently active, and we're ending that one. So currentTouches should be 0 and clear the touchMap.
    // This resolves an issue in iOS where it can sometimes not report a touchend/touchcancel
    if (e.touches.length === 1 && currentIdentifiers.length) {
        currentIdentifiers.length = 0;
        this.touchesMap = {};
    }
    if (currentIdentifiers.length === 0) {
        this.isStarted = false;
        this.invokeRecognizers('onEnd', e);
        if (this.animationQueued) {
            this.animationQueued = false;
            Ext.AnimationQueue.stop('onAnimationFrame', this);
        }
    }
}

});

【讨论】:

    猜你喜欢
    • 2014-04-04
    • 1970-01-01
    • 1970-01-01
    • 2013-12-15
    • 1970-01-01
    • 2014-04-08
    • 1970-01-01
    • 2011-09-15
    • 1970-01-01
    相关资源
    最近更新 更多