mirror of
https://github.com/568071718/creator-collection-view
synced 2025-04-19 23:58:41 +00:00
记录了更新区域,保证只有可见区域变化之后才去更新节点
This commit is contained in:
parent
4dd5167400
commit
aecd893457
@ -1025,6 +1025,9 @@ export class YXCollectionView extends Component {
|
|||||||
rect = this.visibleRect
|
rect = this.visibleRect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 记录最后一次更新的内容范围
|
||||||
|
this.lastReloadVisibleCellsInRect = rect.clone()
|
||||||
|
|
||||||
// 根据可见区域,找出对应的布局属性
|
// 根据可见区域,找出对应的布局属性
|
||||||
let layoutAttributes = this.layout.layoutAttributesForElementsInRect(rect, this)
|
let layoutAttributes = this.layout.layoutAttributesForElementsInRect(rect, this)
|
||||||
|
|
||||||
@ -1093,6 +1096,7 @@ export class YXCollectionView extends Component {
|
|||||||
|
|
||||||
layoutAttributes = []
|
layoutAttributes = []
|
||||||
}
|
}
|
||||||
|
private lastReloadVisibleCellsInRect: cc.Rect = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 节点被回收后需要重新使用时,根据当前回收模式恢复节点的状态,保证节点可见
|
* 节点被回收后需要重新使用时,根据当前回收模式恢复节点的状态,保证节点可见
|
||||||
@ -1124,6 +1128,9 @@ export class YXCollectionView extends Component {
|
|||||||
visibleRect = this.visibleRect
|
visibleRect = this.visibleRect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 记录最后一次回收节点时的内容范围
|
||||||
|
this.lastRecycleInvisibleNodesInRect = visibleRect.clone()
|
||||||
|
|
||||||
const _realFrame = _recycleInvisibleNodes_realFrame
|
const _realFrame = _recycleInvisibleNodes_realFrame
|
||||||
const _contentSize = this.scrollView.content.getContentSize()
|
const _contentSize = this.scrollView.content.getContentSize()
|
||||||
|
|
||||||
@ -1153,6 +1160,7 @@ export class YXCollectionView extends Component {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
private lastRecycleInvisibleNodesInRect: cc.Rect = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调整节点的位置/变换
|
* 调整节点的位置/变换
|
||||||
@ -1293,8 +1301,18 @@ export class YXCollectionView extends Component {
|
|||||||
this.reloadVisibleCells()
|
this.reloadVisibleCells()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.layout.shouldUpdateAttributesForBoundsChange()) {
|
||||||
|
return // 当开启了实时更新节点布局属性时,为了保证实时性,去 onScrolling 里面处理
|
||||||
|
}
|
||||||
|
|
||||||
if ((this.frameInterval <= 1) || (this._frameIdx % this.frameInterval == 0)) {
|
if ((this.frameInterval <= 1) || (this._frameIdx % this.frameInterval == 0)) {
|
||||||
this.reloadVisibleCells()
|
// 检查只有显示区域发生变化了才去更新当前可见节点
|
||||||
|
const visibleRect = this.visibleRect
|
||||||
|
let boundsChange = this.lastReloadVisibleCellsInRect == null || this.lastReloadVisibleCellsInRect.equals(visibleRect) == false
|
||||||
|
if (boundsChange) {
|
||||||
|
this.reloadVisibleCells(visibleRect)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1311,7 +1329,12 @@ export class YXCollectionView extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((this.recycleInterval >= 1) && (this._frameIdx % this.recycleInterval == 0)) {
|
if ((this.recycleInterval >= 1) && (this._frameIdx % this.recycleInterval == 0)) {
|
||||||
this.recycleInvisibleNodes()
|
// 检查只有显示区域发生变化了才去回收当前可见节点
|
||||||
|
const visibleRect = this.visibleRect
|
||||||
|
let boundsChange = this.lastRecycleInvisibleNodesInRect == null || this.lastRecycleInvisibleNodesInRect.equals(visibleRect) == false
|
||||||
|
if (boundsChange) {
|
||||||
|
this.recycleInvisibleNodes(visibleRect)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1026,6 +1026,9 @@ export class YXCollectionView extends Component {
|
|||||||
rect = this.visibleRect
|
rect = this.visibleRect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 记录最后一次更新的内容范围
|
||||||
|
this.lastReloadVisibleCellsInRect = rect.clone()
|
||||||
|
|
||||||
// 根据可见区域,找出对应的布局属性
|
// 根据可见区域,找出对应的布局属性
|
||||||
let layoutAttributes = this.layout.layoutAttributesForElementsInRect(rect, this)
|
let layoutAttributes = this.layout.layoutAttributesForElementsInRect(rect, this)
|
||||||
|
|
||||||
@ -1094,6 +1097,7 @@ export class YXCollectionView extends Component {
|
|||||||
|
|
||||||
layoutAttributes = []
|
layoutAttributes = []
|
||||||
}
|
}
|
||||||
|
private lastReloadVisibleCellsInRect: math.Rect = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 节点被回收后需要重新使用时,根据当前回收模式恢复节点的状态,保证节点可见
|
* 节点被回收后需要重新使用时,根据当前回收模式恢复节点的状态,保证节点可见
|
||||||
@ -1133,6 +1137,9 @@ export class YXCollectionView extends Component {
|
|||||||
visibleRect = this.visibleRect
|
visibleRect = this.visibleRect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 记录最后一次回收节点时的内容范围
|
||||||
|
this.lastRecycleInvisibleNodesInRect = visibleRect.clone()
|
||||||
|
|
||||||
const _realFrame = _recycleInvisibleNodes_realFrame
|
const _realFrame = _recycleInvisibleNodes_realFrame
|
||||||
const _contentSize = this.scrollView.content.getComponent(UITransform).contentSize
|
const _contentSize = this.scrollView.content.getComponent(UITransform).contentSize
|
||||||
|
|
||||||
@ -1162,6 +1169,7 @@ export class YXCollectionView extends Component {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
private lastRecycleInvisibleNodesInRect: math.Rect = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调整节点的位置/变换
|
* 调整节点的位置/变换
|
||||||
@ -1302,8 +1310,18 @@ export class YXCollectionView extends Component {
|
|||||||
this.reloadVisibleCells()
|
this.reloadVisibleCells()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.layout.shouldUpdateAttributesForBoundsChange()) {
|
||||||
|
return // 当开启了实时更新节点布局属性时,为了保证实时性,去 onScrolling 里面处理
|
||||||
|
}
|
||||||
|
|
||||||
if ((this.frameInterval <= 1) || (this._frameIdx % this.frameInterval == 0)) {
|
if ((this.frameInterval <= 1) || (this._frameIdx % this.frameInterval == 0)) {
|
||||||
this.reloadVisibleCells()
|
// 检查只有显示区域发生变化了才去更新当前可见节点
|
||||||
|
const visibleRect = this.visibleRect
|
||||||
|
let boundsChange = this.lastReloadVisibleCellsInRect == null || this.lastReloadVisibleCellsInRect.equals(visibleRect) == false
|
||||||
|
if (boundsChange) {
|
||||||
|
this.reloadVisibleCells(visibleRect)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1320,7 +1338,12 @@ export class YXCollectionView extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((this.recycleInterval >= 1) && (this._frameIdx % this.recycleInterval == 0)) {
|
if ((this.recycleInterval >= 1) && (this._frameIdx % this.recycleInterval == 0)) {
|
||||||
this.recycleInvisibleNodes()
|
// 检查只有显示区域发生变化了才去回收当前可见节点
|
||||||
|
const visibleRect = this.visibleRect
|
||||||
|
let boundsChange = this.lastRecycleInvisibleNodesInRect == null || this.lastRecycleInvisibleNodesInRect.equals(visibleRect) == false
|
||||||
|
if (boundsChange) {
|
||||||
|
this.recycleInvisibleNodes(visibleRect)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user