2010-08-19 73 views
0

我有兩個Ext.Panels,一個是ScrollingContent,另一個叫做wrapper。包裝比滾動內容小,所以後者在包裝內滾動。如何在Ext Touch(Sencha Touch)中處理Ext.Panels上的滾動事件?

我想在每次滾動後處理滾動事件和滾動內容的位置。

我沒有找到任何解決方案。任何幫助真的很感激。

在此先感謝

var scrollingContent = new Ext.Panel({ 
    id: 'p1', 
    layout: 'hbox', 
    width: 1200, 
    height: 380, 
    //cls: 'blue', 
    items: itemList 
}); 

var wrapper = new Ext.Panel({ 
    id: 'p2', 
    scroll: 'horizontal', 
    width: 800, 
    height: 380, 
    cls: 'gray', 
    items: scrollingContent 
}); 

回答

5

要訪問包裝的滾動事件,訪問其滾輪它之後呈現:

var wrapper = new Ext.Panel({ 
    id: 'p2', 
    scroll: 'horizontal', 
    width: 800, 
    height: 380, 
    cls: 'gray', 
    items: scrollingContent, 

    listeners: { 
     afterrender: function(comp) { 
      // comp is this Ext.Component == wrapper 
      comp.scroller.on('scroll',handleScroll); 
     } 
    } 
}); 

/** 
* Called when wrapper scrolls 
*/ 
function handleScroll(scrollerObject,offsetObject) { 
    // Do your stuff here 
} 

請注意,本次活動將持續火,不只是當滾動開始。如果您需要該功能,請改爲使用scrollstart事件。

此處,我發現了信息: http://www.sencha.com/forum/showthread.php?110240-How-to-add-scroll-event-to-Ext.form.FormPanel&s=a478f8ee91ba4cfde57845bf6229c902

欲瞭解更多信息,滾輪類和它所暴露,請參閱API文檔: http://dev.sencha.com/deploy/touch/docs/?class=Ext.util.Scroller