@tanstack/virtual-core
Advanced tools
Comparing version 3.9.0 to 3.10.1
@@ -370,3 +370,2 @@ import { debounce, memo, notUndefined, approxEqual } from "./utils.js"; | ||
({ count, paddingStart, scrollMargin, getItemKey, enabled }, itemSizeCache) => { | ||
var _a; | ||
if (!enabled) { | ||
@@ -387,29 +386,2 @@ this.measurementsCache = []; | ||
for (let i = min; i < count; i++) { | ||
let measureElement2 = (_a = this.measurementsCache[i]) == null ? void 0 : _a.measureElement; | ||
if (!measureElement2) { | ||
measureElement2 = (node) => { | ||
const key2 = getItemKey(i); | ||
const prevNode = this.elementsCache.get(key2); | ||
if (!node) { | ||
if (prevNode) { | ||
this.observer.unobserve(prevNode); | ||
this.elementsCache.delete(key2); | ||
} | ||
return; | ||
} | ||
if (prevNode !== node) { | ||
if (prevNode) { | ||
this.observer.unobserve(prevNode); | ||
} | ||
this.observer.observe(node); | ||
this.elementsCache.set(key2, node); | ||
} | ||
if (node.isConnected) { | ||
this.resizeItem( | ||
i, | ||
this.options.measureElement(node, void 0, this) | ||
); | ||
} | ||
}; | ||
} | ||
const key = getItemKey(i); | ||
@@ -429,3 +401,3 @@ const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i); | ||
lane, | ||
measureElement: measureElement2 | ||
measureElement: this.measureElement | ||
}; | ||
@@ -487,14 +459,5 @@ } | ||
this._measureElement = (node, entry) => { | ||
const i = this.indexFromElement(node); | ||
const item = this.getMeasurements()[i]; | ||
if (!item || !node.isConnected) { | ||
this.elementsCache.forEach((cached, key) => { | ||
if (cached === node) { | ||
this.observer.unobserve(node); | ||
this.elementsCache.delete(key); | ||
} | ||
}); | ||
return; | ||
} | ||
const prevNode = this.elementsCache.get(item.key); | ||
const index = this.indexFromElement(node); | ||
const key = this.options.getItemKey(index); | ||
const prevNode = this.elementsCache.get(key); | ||
if (prevNode !== node) { | ||
@@ -505,5 +468,7 @@ if (prevNode) { | ||
this.observer.observe(node); | ||
this.elementsCache.set(item.key, node); | ||
this.elementsCache.set(key, node); | ||
} | ||
this.resizeItem(i, this.options.measureElement(node, entry, this)); | ||
if (node.isConnected) { | ||
this.resizeItem(index, this.options.measureElement(node, entry, this)); | ||
} | ||
}; | ||
@@ -534,2 +499,8 @@ this.resizeItem = (index, size) => { | ||
if (!node) { | ||
this.elementsCache.forEach((cached, key) => { | ||
if (!cached.isConnected) { | ||
this.observer.unobserve(cached); | ||
this.elementsCache.delete(key); | ||
} | ||
}); | ||
return; | ||
@@ -536,0 +507,0 @@ } |
{ | ||
"name": "@tanstack/virtual-core", | ||
"version": "3.9.0", | ||
"version": "3.10.1", | ||
"description": "Headless UI for virtualizing scrollable elements in TS/JS + Frameworks", | ||
@@ -5,0 +5,0 @@ "author": "Tanner Linsley", |
@@ -618,34 +618,2 @@ import { approxEqual, debounce, memo, notUndefined } from './utils' | ||
for (let i = min; i < count; i++) { | ||
let measureElement = this.measurementsCache[i]?.measureElement | ||
if (!measureElement) { | ||
measureElement = (node: TItemElement | null | undefined) => { | ||
const key = getItemKey(i) | ||
const prevNode = this.elementsCache.get(key) | ||
if (!node) { | ||
if (prevNode) { | ||
this.observer.unobserve(prevNode) | ||
this.elementsCache.delete(key) | ||
} | ||
return | ||
} | ||
if (prevNode !== node) { | ||
if (prevNode) { | ||
this.observer.unobserve(prevNode) | ||
} | ||
this.observer.observe(node) | ||
this.elementsCache.set(key, node) | ||
} | ||
if (node.isConnected) { | ||
this.resizeItem( | ||
i, | ||
this.options.measureElement(node, undefined, this), | ||
) | ||
} | ||
} | ||
} | ||
const key = getItemKey(i) | ||
@@ -681,3 +649,3 @@ | ||
lane, | ||
measureElement, | ||
measureElement: this.measureElement, | ||
} | ||
@@ -755,17 +723,7 @@ } | ||
) => { | ||
const i = this.indexFromElement(node) | ||
const item = this.getMeasurements()[i] | ||
const index = this.indexFromElement(node) | ||
const key = this.options.getItemKey(index) | ||
if (!item || !node.isConnected) { | ||
this.elementsCache.forEach((cached, key) => { | ||
if (cached === node) { | ||
this.observer.unobserve(node) | ||
this.elementsCache.delete(key) | ||
} | ||
}) | ||
return | ||
} | ||
const prevNode = this.elementsCache.get(key) | ||
const prevNode = this.elementsCache.get(item.key) | ||
if (prevNode !== node) { | ||
@@ -776,6 +734,8 @@ if (prevNode) { | ||
this.observer.observe(node) | ||
this.elementsCache.set(item.key, node) | ||
this.elementsCache.set(key, node) | ||
} | ||
this.resizeItem(i, this.options.measureElement(node, entry, this)) | ||
if (node.isConnected) { | ||
this.resizeItem(index, this.options.measureElement(node, entry, this)) | ||
} | ||
} | ||
@@ -816,2 +776,8 @@ | ||
if (!node) { | ||
this.elementsCache.forEach((cached, key) => { | ||
if (!cached.isConnected) { | ||
this.observer.unobserve(cached) | ||
this.elementsCache.delete(key) | ||
} | ||
}) | ||
return | ||
@@ -818,0 +784,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
193086
2676