Egretコンポーネントを順番に配置したときのDrawDraw最適化のアイデア

Scollerまたはリストコンポーネントは、垂直画面アイテムでの垂直ソート、または水平ソートに使用できます。

アイデア:スクロールプロセス中、ユーザーの可視領域を超える一部のコンポーネントは非表示になり、表示するために可視領域の前後で特定の範囲にスクロールされます。

スクロールイベント:

this .MainList.addEventListener(eui.UIEvent.CHANGE、(e)=> {}、this);

ユーザーの表示領域を基準にして、Scrollerのサブコンポーネントの座標を取得します。

let point = self.MainListBox.localToGlobal(item.x、item.y)

表示非表示の制御:<Component> .visible = <boolean>を使用します

解像度をしましょう;
if(point.y <0-item.height * 2 || point.y> self.stage.stageHeight + item.height * 2 ){
    ログ(item [ 'floor']、 'need to hide' 、point.x、point.y)
    res = false ;
} その他{
    ログ(item [ 'floor']、 'Need to display' 、point.x、point.y)
    res = true ;
}
item [ 'showhide'](res); //<Component>.visible = <boolean>

サンプルコード:

let self = this 
self.MainList.addEventListener(eui.UIEvent.CHANGE、(e) => {
    self.MainListBox。$ children.forEach((item、i) => {
        let point = self.MainListBox.localToGlobal(item.x、item.y)
        解像度をしましょう;
        if(point.y <0-item.height * 2 || point.y> self.stage.stageHeight + item.height * 2 ){
            ログ(item [ 'floor']、 'need to hide' 、point.x、point.y)
            res = false ;
        } その他{
            ログ(item [ 'floor']、 'Need to display' 、point.x、point.y)
            res = true ;
        }
        item [ 'showhide' ](res);
    })
}、これ);

私のプロジェクトでは、テスト前後の2つのサブコンポーネントの高さが予約されており、スクロールプロセス中にスタックが発生しません

おすすめ

転載: www.cnblogs.com/webfs/p/12697018.html