Skip to content

Commit

Permalink
fix: bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuever committed Oct 16, 2023
1 parent d409bcc commit e4d4bfc
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 48 deletions.
2 changes: 1 addition & 1 deletion packages/data-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@x-oasis/noop": "^0.1.14",
"@x-oasis/omit": "^0.1.14",
"@x-oasis/prefix-interval-tree": "^0.1.18",
"@x-oasis/recycler": "^0.1.32",
"@x-oasis/recycler": "^0.1.33",
"@x-oasis/resolve-changed": "^0.1.14",
"@x-oasis/select-value": "^0.1.14",
"@x-oasis/shallow-array-equal": "^0.1.14",
Expand Down
2 changes: 1 addition & 1 deletion packages/data-model/src/ItemMetaStateEventHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class ItemMetaStateEventHelper {
this._handleCountMap.set(handler, value + 1);
const key = getByValue(this._reusableStrictEventListenerMap, handler);
if (key) {
const _value = this._strictListenerKeyToHandleCountMap[key];
const _value = this._strictListenerKeyToHandleCountMap[key] || 0;
this._strictListenerKeyToHandleCountMap[key] = _value + 1;
}
}
Expand Down
73 changes: 38 additions & 35 deletions packages/data-model/src/ListBaseDimensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ abstract class ListBaseDimensions<ItemT extends {} = {}> extends BaseLayout {
this._onRecyclerProcess = onRecyclerProcess;
this._releaseSpaceStateItem = releaseSpaceStateItem;
this.stillnessHandler = this.stillnessHandler.bind(this);
this._store = store
this._store = store;

this.onEndReachedHelper = new OnEndReachedHelper({
id: this.id,
Expand Down Expand Up @@ -155,6 +155,7 @@ abstract class ListBaseDimensions<ItemT extends {} = {}> extends BaseLayout {
const indexInfo = meta.getIndexInfo();
return indexInfo?.indexInGroup;
},
getMetaType: (meta) => meta.recyclerType,
getType: (index) => this.getFinalIndexItemMeta(index)?.recyclerType,
});
this.initializeDefaultRecycleBuffer();
Expand Down Expand Up @@ -196,7 +197,7 @@ abstract class ListBaseDimensions<ItemT extends {} = {}> extends BaseLayout {
}

initializeDefaultRecycleBuffer() {
this.addBuffer(DEFAULT_RECYCLER_TYPE)
this.addBuffer(DEFAULT_RECYCLER_TYPE);
}

get length() {
Expand Down Expand Up @@ -244,11 +245,11 @@ abstract class ListBaseDimensions<ItemT extends {} = {}> extends BaseLayout {
}

initializeState() {
this._state = this.resolveInitialState()
this._state = this.resolveInitialState();
this._stateResult =
this.fillingMode === FillingMode.RECYCLE
? this.memoizedResolveRecycleState(this._state)
: this.memoizedResolveSpaceState(this._state);
this.fillingMode === FillingMode.RECYCLE
? this.memoizedResolveRecycleState(this._state)
: this.memoizedResolveSpaceState(this._state);
}

resolveInitialState() {
Expand Down Expand Up @@ -657,20 +658,21 @@ abstract class ListBaseDimensions<ItemT extends {} = {}> extends BaseLayout {

if (indexToOffsetMap[targetIndex] != null) {
const itemMetaState =
!this._scrollMetrics || !itemMeta?.getLayout()
? itemMeta
? itemMeta.getState()
: {}
: this._configTuple.resolveItemMetaState(
itemMeta,
this._scrollMetrics,
// should add container offset, because indexToOffsetMap containerOffset is
// exclusive.
() =>
indexToOffsetMap[targetIndex] == null
? this.itemOffsetBeforeLayoutReady
: indexToOffsetMap[targetIndex] + this.getContainerOffset()
);
!this._scrollMetrics || !itemMeta?.getLayout()
? itemMeta
? itemMeta.getState()
: {}
: this._configTuple.resolveItemMetaState(
itemMeta,
this._scrollMetrics,
// should add container offset, because indexToOffsetMap containerOffset is
// exclusive.
() =>
indexToOffsetMap[targetIndex] == null
? this.itemOffsetBeforeLayoutReady
: indexToOffsetMap[targetIndex] +
this.getContainerOffset()
);

itemMeta?.setItemMetaState(itemMetaState);
}
Expand Down Expand Up @@ -784,21 +786,22 @@ abstract class ListBaseDimensions<ItemT extends {} = {}> extends BaseLayout {
});
if (indexToOffsetMap[targetIndex] != null) {
const itemMetaState =
!this._scrollMetrics || !itemMeta?.getLayout()
? itemMeta
? itemMeta.getState()
: {}
: this._configTuple.resolveItemMetaState(
itemMeta,
this._scrollMetrics,
// should add container offset, because indexToOffsetMap containerOffset is
// exclusive.
() =>
indexToOffsetMap[targetIndex] == null
? this.itemOffsetBeforeLayoutReady
: indexToOffsetMap[targetIndex] + this.getContainerOffset()
);

!this._scrollMetrics || !itemMeta?.getLayout()
? itemMeta
? itemMeta.getState()
: {}
: this._configTuple.resolveItemMetaState(
itemMeta,
this._scrollMetrics,
// should add container offset, because indexToOffsetMap containerOffset is
// exclusive.
() =>
indexToOffsetMap[targetIndex] == null
? this.itemOffsetBeforeLayoutReady
: indexToOffsetMap[targetIndex] +
this.getContainerOffset()
);

// 触发打点
itemMeta?.setItemMetaState(itemMetaState);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/data-model/src/ListGroupDimensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class ListGroupDimensionsExperimental<
if (info) return info.startIndex;
}

return 0;
return -1;
}

/**
Expand Down
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e4d4bfc

Please sign in to comment.