Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@infinite-list/data-model

Package Overview
Dependencies
Maintainers
1
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@infinite-list/data-model - npm Package Compare versions

Comparing version 0.2.20-stillness.1 to 0.2.20

3

dist/ListDimensions.d.ts

@@ -38,3 +38,2 @@ import Batchinator from '@x-oasis/batchinator';

private _offsetTriggerCachedState;
private _stillnessHelper;
private memoizedResolveSpaceState;

@@ -134,6 +133,4 @@ private memoizedResolveRecycleState;

dispatchScrollMetricsEnabled(): boolean;
stillnessHandler(): void;
isStill(): void;
updateScrollMetrics(scrollMetrics?: ScrollMetrics, useCache?: boolean): void;
}
export default ListDimensions;

@@ -62,3 +62,2 @@ import BaseDimensions from '../BaseDimensions';

recycleEnabled?: boolean;
stillnessThreshold?: number;
dispatchMetricsThreshold?: number;

@@ -181,3 +180,2 @@ } & BaseDimensionsProps & OnEndReachedHelperProps;

targetKey: string;
targetIndex: number;
offset: number;

@@ -184,0 +182,0 @@ } & SpaceStateToken<ItemT>;

2

package.json
{
"name": "@infinite-list/data-model",
"version": "0.2.20-stillness.1",
"version": "0.2.20",
"files": [

@@ -5,0 +5,0 @@ "dist",

@@ -11,3 +11,2 @@ export const DEFAULT_LAYOUT = {

export const ON_END_REACHED_HANDLER_TIMEOUT_THRESHOLD = 1000;
export const DISPATCH_METRICS_THRESHOLD = 50;

@@ -14,0 +13,0 @@

@@ -50,3 +50,2 @@ import noop from '@x-oasis/noop';

import shallowArrayEqual from '@x-oasis/shallow-array-equal';
import StillnessHelper from './utils/StillnessHelper';

@@ -105,4 +104,2 @@ class ListDimensions<ItemT extends {} = {}> extends BaseDimensions {

private _stillnessHelper: StillnessHelper;
private memoizedResolveSpaceState: (

@@ -134,6 +131,5 @@ state: ListState<ItemT>

persistanceIndices,
stillnessThreshold,
dispatchMetricsThreshold = DISPATCH_METRICS_THRESHOLD,
onEndReachedTimeoutThreshold,
onEndReachedHandlerTimeoutThreshold,
dispatchMetricsThreshold = DISPATCH_METRICS_THRESHOLD,
} = props;

@@ -158,8 +154,2 @@ this._keyExtractor = keyExtractor;

this.stillnessHandler = this.stillnessHandler.bind(this);
this._stillnessHelper = new StillnessHelper({
stillnessThreshold,
handler: this.stillnessHandler,
});
this._deps = deps;

@@ -987,4 +977,3 @@ this._isActive = this.resolveInitialActiveValue(active);

const _targetIndices = this._bufferSet.indices.map((i) => parseInt(i));
const targetIndices = new Array(_targetIndices.length).fill(null);
const targetIndices = this._bufferSet.indices.map((i) => parseInt(i));

@@ -1004,4 +993,4 @@ // const scrolling = actionType === 'scrollDown' || actionType === 'scrollUp';

index,
visibleStartIndex - 2,
visibleEndIndex + 2
visibleStartIndex,
visibleEndIndex
);

@@ -1016,5 +1005,2 @@ if (position !== null) targetIndices[position] = index;

let _beforeCount = 0;
let _topMinIndex = visibleStartIndex;
for (

@@ -1025,28 +1011,11 @@ let index = visibleStartIndex, size = beforeSize;

) {
const item = data[index];
if (!item) continue;
const itemMeta = this.getItemMeta(item, index);
const itemLayout = itemMeta?.getLayout();
const position = this.getPosition(
index,
bufferedStartIndex,
visibleStartIndex
);
if (_beforeCount < 2 || !itemLayout) {
const position = this.getPosition(
index,
visibleStartIndex - 2,
visibleEndIndex + 2
);
_topMinIndex = index;
if (position !== null) targetIndices[position] = index;
} else {
break;
}
if (index >= this.initialNumToRender) {
_beforeCount++;
}
if (position !== null) targetIndices[position] = index;
}
let _afterCount = 0;
let _bottomMaxIndex = visibleEndIndex + 1;
for (

@@ -1057,22 +1026,8 @@ let index = visibleEndIndex + 1, size = afterSize;

) {
const item = data[index];
if (!item) continue;
const itemMeta = this.getItemMeta(item, index);
const itemLayout = itemMeta?.getLayout();
if (_afterCount < 2 || !itemLayout) {
const position = this.getPosition(
index,
visibleStartIndex - 2,
visibleEndIndex + 2
);
_bottomMaxIndex = index;
if (position !== null) targetIndices[position] = index;
} else {
break;
}
if (index >= this.initialNumToRender) {
_afterCount++;
}
const position = this.getPosition(
index,
visibleEndIndex + 1,
bufferedEndIndex
);
if (position !== null) targetIndices[position] = index;
}

@@ -1088,81 +1043,3 @@

let topOffset = indexToOffsetMap[Math.max(_topMinIndex, 0)] || 0;
let bottomOffset = indexToOffsetMap[Math.max(_bottomMaxIndex, 0)] || 0;
targetIndices.forEach((targetIndex, index) => {
// const prevStateResult = this._stateResult as RecycleStateResult<ItemT>;
// targetIndex is null or undefined
if (targetIndex == null) {
// if (prevStateResult?.recycleState) {
// const _result = prevStateResult.recycleState[index];
// if (_result) {
// const { item, targetKey } = _result;
// // maybe item has been deleted
// if (item === this._data[this.getKeyIndex(targetKey)]) {
// const { targetIndex, offset: _offset } = _result;
// if (targetIndex < visibleStartIndex) {
// const offset = indexToOffsetMap[negativeStartIndex--];
// if (typeof offset === 'number')
// recycleStateResult.push({
// ..._result,
// offset: offset || _offset,
// });
// } else if (targetIndex > visibleStartIndex) {
// const offset = indexToOffsetMap[positiveStartIndex++];
// if (typeof offset === 'number')
// recycleStateResult.push({
// ..._result,
// offset: offset || _offset,
// });
// }
// }
// }
// }
// return;
targetIndex = _targetIndices[index];
const item = data[targetIndex];
if (!item) return;
const itemKey = this.getItemKey(item, targetIndex);
const itemMeta = this.getItemMeta(item, targetIndex);
const itemLayout = itemMeta?.getLayout();
const itemLength =
(itemLayout?.height || 0) + (itemMeta?.getSeparatorLength() || 0);
let offset = 0;
if (this._scrollMetrics && itemLayout) {
const velocity = this._scrollMetrics.velocity;
// scroll up, preserve start
if (velocity < 0) {
topOffset -= itemLength;
offset = topOffset;
// scroll down, preserve end
} else if (velocity > 0) {
bottomOffset += itemLength;
offset = bottomOffset;
} else {
if (targetIndex < visibleStartIndex) {
topOffset -= itemLength;
offset = topOffset;
} else {
bottomOffset += itemLength;
offset = bottomOffset;
}
}
}
recycleStateResult.push({
key: `recycle_${index}`,
targetKey: itemKey,
targetIndex,
length: itemLength,
isSpace: false,
isSticky: false,
item,
// 如果没有offset,说明item是新增的,那么它渲染就在最开始位置好了
offset: itemLayout ? offset : 0,
position: 'buffered',
});
return;
}
const item = data[targetIndex];

@@ -1195,3 +1072,2 @@ if (!item) return;

targetKey: itemKey,
targetIndex,
length: itemLength,

@@ -1212,4 +1088,4 @@ isSpace: false,

const stateResult = {
recycleState: recycleStateResult.filter((v) => v),
spaceState: spaceStateResult.filter((v) => v),
recycleState: recycleStateResult,
spaceState: spaceStateResult,
};

@@ -1482,10 +1358,2 @@

stillnessHandler() {
this.dispatchMetrics(this._scrollMetrics);
}
isStill() {
this._stillnessHelper.isStill;
}
/**

@@ -1514,6 +1382,2 @@ * When to trigger updateScrollMetrics..

if (this._scrollMetrics?.offset !== scrollMetrics?.offset) {
// this._stillnessHelper.startClockBatchinateLast.schedule();
}
if (

@@ -1520,0 +1384,0 @@ !this._scrollMetrics ||

@@ -82,4 +82,2 @@ import BaseDimensions from '../BaseDimensions';

stillnessThreshold?: number;
dispatchMetricsThreshold?: number;

@@ -234,3 +232,2 @@ } & BaseDimensionsProps &

targetKey: string;
targetIndex: number;
offset: number;

@@ -237,0 +234,0 @@ } & SpaceStateToken<ItemT>;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc