@react-stately/virtualizer
Advanced tools
Comparing version 3.0.0-nightly-0ddbe6f95-241021 to 3.0.0-nightly-10a43de88-241127
@@ -35,3 +35,4 @@ | ||
var _this_getLayoutInfo; | ||
return (_this_getLayoutInfo = this.getLayoutInfo(key)) === null || _this_getLayoutInfo === void 0 ? void 0 : _this_getLayoutInfo.rect; | ||
var _this_getLayoutInfo_rect; | ||
return (_this_getLayoutInfo_rect = (_this_getLayoutInfo = this.getLayoutInfo(key)) === null || _this_getLayoutInfo === void 0 ? void 0 : _this_getLayoutInfo.rect) !== null && _this_getLayoutInfo_rect !== void 0 ? _this_getLayoutInfo_rect : null; | ||
} | ||
@@ -41,2 +42,5 @@ getVisibleRect() { | ||
} | ||
constructor(){ | ||
/** The Virtualizer the layout is currently attached to. */ this.virtualizer = null; | ||
} | ||
} | ||
@@ -43,0 +47,0 @@ |
@@ -29,3 +29,4 @@ /* | ||
var _this_getLayoutInfo; | ||
return (_this_getLayoutInfo = this.getLayoutInfo(key)) === null || _this_getLayoutInfo === void 0 ? void 0 : _this_getLayoutInfo.rect; | ||
var _this_getLayoutInfo_rect; | ||
return (_this_getLayoutInfo_rect = (_this_getLayoutInfo = this.getLayoutInfo(key)) === null || _this_getLayoutInfo === void 0 ? void 0 : _this_getLayoutInfo.rect) !== null && _this_getLayoutInfo_rect !== void 0 ? _this_getLayoutInfo_rect : null; | ||
} | ||
@@ -35,2 +36,5 @@ getVisibleRect() { | ||
} | ||
constructor(){ | ||
/** The Virtualizer the layout is currently attached to. */ this.virtualizer = null; | ||
} | ||
} | ||
@@ -37,0 +41,0 @@ |
@@ -7,2 +7,3 @@ | ||
$parcel$export(module.exports, "ReusableView", () => $197a1781bd47f5b9$export$1a5223887c560441); | ||
$parcel$export(module.exports, "RootView", () => $197a1781bd47f5b9$export$e21886a4eef6b29a); | ||
/* | ||
@@ -33,5 +34,3 @@ * Copyright 2020 Adobe. All rights reserved. | ||
let reusable = this.reusableViews.get(reuseType); | ||
let view = (reusable === null || reusable === void 0 ? void 0 : reusable.length) > 0 ? reusable.shift() : new $197a1781bd47f5b9$export$1a5223887c560441(this.virtualizer); | ||
view.viewType = reuseType; | ||
view.parent = this; | ||
let view = reusable && reusable.length > 0 ? reusable.shift() : new $197a1781bd47f5b9$export$7a41b6f219e61634(this.virtualizer, this, reuseType); | ||
return view; | ||
@@ -48,12 +47,26 @@ } | ||
} | ||
constructor(virtualizer){ | ||
constructor(virtualizer, viewType){ | ||
this.virtualizer = virtualizer; | ||
this.key = ++$197a1781bd47f5b9$var$KEY; | ||
this.parent = null; | ||
this.viewType = viewType; | ||
this.children = new Set(); | ||
this.reusableViews = new Map(); | ||
this.layoutInfo = null; | ||
this.content = null; | ||
this.rendered = null; | ||
} | ||
} | ||
class $197a1781bd47f5b9$export$e21886a4eef6b29a extends $197a1781bd47f5b9$export$1a5223887c560441 { | ||
constructor(virtualizer){ | ||
super(virtualizer, 'root'); | ||
} | ||
} | ||
class $197a1781bd47f5b9$export$7a41b6f219e61634 extends $197a1781bd47f5b9$export$1a5223887c560441 { | ||
constructor(virtualizer, parent, viewType){ | ||
super(virtualizer, viewType); | ||
this.parent = parent; | ||
} | ||
} | ||
//# sourceMappingURL=ReusableView.main.js.map |
@@ -26,5 +26,3 @@ /* | ||
let reusable = this.reusableViews.get(reuseType); | ||
let view = (reusable === null || reusable === void 0 ? void 0 : reusable.length) > 0 ? reusable.shift() : new $ad1d98aa8f0c31b4$export$1a5223887c560441(this.virtualizer); | ||
view.viewType = reuseType; | ||
view.parent = this; | ||
let view = reusable && reusable.length > 0 ? reusable.shift() : new $ad1d98aa8f0c31b4$export$7a41b6f219e61634(this.virtualizer, this, reuseType); | ||
return view; | ||
@@ -41,13 +39,27 @@ } | ||
} | ||
constructor(virtualizer){ | ||
constructor(virtualizer, viewType){ | ||
this.virtualizer = virtualizer; | ||
this.key = ++$ad1d98aa8f0c31b4$var$KEY; | ||
this.parent = null; | ||
this.viewType = viewType; | ||
this.children = new Set(); | ||
this.reusableViews = new Map(); | ||
this.layoutInfo = null; | ||
this.content = null; | ||
this.rendered = null; | ||
} | ||
} | ||
class $ad1d98aa8f0c31b4$export$e21886a4eef6b29a extends $ad1d98aa8f0c31b4$export$1a5223887c560441 { | ||
constructor(virtualizer){ | ||
super(virtualizer, 'root'); | ||
} | ||
} | ||
class $ad1d98aa8f0c31b4$export$7a41b6f219e61634 extends $ad1d98aa8f0c31b4$export$1a5223887c560441 { | ||
constructor(virtualizer, parent, viewType){ | ||
super(virtualizer, viewType); | ||
this.parent = parent; | ||
} | ||
} | ||
export {$ad1d98aa8f0c31b4$export$1a5223887c560441 as ReusableView}; | ||
export {$ad1d98aa8f0c31b4$export$1a5223887c560441 as ReusableView, $ad1d98aa8f0c31b4$export$7a41b6f219e61634 as ChildView, $ad1d98aa8f0c31b4$export$e21886a4eef6b29a as RootView}; | ||
//# sourceMappingURL=ReusableView.module.js.map |
@@ -193,10 +193,9 @@ import { Key, Collection, ItemDropTarget, LayoutDelegate } from "@react-types/shared"; | ||
/** The content currently being displayed by this view, set by the virtualizer. */ | ||
content: T; | ||
rendered: V; | ||
content: T | null; | ||
rendered: V | null; | ||
viewType: string; | ||
key: Key; | ||
parent: ReusableView<T, V> | null; | ||
children: Set<ReusableView<T, V>>; | ||
reusableViews: Map<string, ReusableView<T, V>[]>; | ||
constructor(virtualizer: Virtualizer<T, V>); | ||
children: Set<ChildView<T, V>>; | ||
reusableViews: Map<string, ChildView<T, V>[]>; | ||
constructor(virtualizer: Virtualizer<T, V>, viewType: string); | ||
/** | ||
@@ -206,5 +205,14 @@ * Prepares the view for reuse. Called just before the view is removed from the DOM. | ||
prepareForReuse(): void; | ||
getReusableView(reuseType: string): ReusableView<T, V>; | ||
reuseChild(child: ReusableView<T, V>): void; | ||
getReusableView(reuseType: string): ChildView<T, V>; | ||
reuseChild(child: ChildView<T, V>): void; | ||
} | ||
declare class ChildView<T extends object, V> extends ReusableView<T, V> { | ||
parent: ReusableView<T, V>; | ||
constructor(virtualizer: Virtualizer<T, V>, parent: ReusableView<T, V>, viewType: string); | ||
} | ||
interface VirtualizerOptions<T extends object, V> { | ||
delegate: VirtualizerDelegate<T, V>; | ||
collection: Collection<T>; | ||
layout: Layout<T>; | ||
} | ||
/** | ||
@@ -242,3 +250,3 @@ * The Virtualizer class renders a scrollable collection of data using customizable layouts. | ||
readonly persistedKeys: Set<Key>; | ||
constructor(delegate: VirtualizerDelegate<T, V>); | ||
constructor(options: VirtualizerOptions<T, V>); | ||
/** Returns whether the given key, or an ancestor, is persisted. */ | ||
@@ -272,3 +280,3 @@ isPersistedKey(key: Key): boolean; | ||
/** The Virtualizer the layout is currently attached to. */ | ||
virtualizer: Virtualizer<T, any>; | ||
virtualizer: Virtualizer<T, any> | null; | ||
/** | ||
@@ -312,3 +320,3 @@ * Returns whether the layout should invalidate in response to | ||
getDropTargetLayoutInfo?(target: ItemDropTarget): LayoutInfo; | ||
getItemRect(key: Key): Rect; | ||
getItemRect(key: Key): Rect | null; | ||
getVisibleRect(): Rect; | ||
@@ -325,3 +333,3 @@ } | ||
setVisibleRect(rect: Rect): void; | ||
renderView(type: string, content: T): V; | ||
renderView(type: string, content: T | null): V; | ||
invalidate(ctx: InvalidationContext): void; | ||
@@ -332,3 +340,3 @@ } | ||
collection: Collection<T>; | ||
persistedKeys?: Set<Key>; | ||
persistedKeys?: Set<Key> | null; | ||
visibleRect: Rect; | ||
@@ -340,3 +348,3 @@ invalidationContext: InvalidationContext; | ||
interface VirtualizerProps<T extends object, V, O> { | ||
renderView(type: string, content: T): V; | ||
renderView(type: string, content: T | null): V; | ||
layout: Layout<T>; | ||
@@ -343,0 +351,0 @@ collection: Collection<T>; |
@@ -32,9 +32,13 @@ var $41b7691783731623$exports = require("./Rect.main.js"); | ||
let [virtualizer] = (0, $amfZP$react.useState)(()=>new (0, $e1bc15d49d21df0e$exports.Virtualizer)({ | ||
setVisibleRect (rect) { | ||
setVisibleRect(rect); | ||
visibleRectChanged.current = true; | ||
}, | ||
// TODO: should changing these invalidate the entire cache? | ||
renderView: opts.renderView, | ||
invalidate: setInvalidationContext | ||
collection: opts.collection, | ||
layout: opts.layout, | ||
delegate: { | ||
setVisibleRect (rect) { | ||
setVisibleRect(rect); | ||
visibleRectChanged.current = true; | ||
}, | ||
// TODO: should changing these invalidate the entire cache? | ||
renderView: opts.renderView, | ||
invalidate: setInvalidationContext | ||
} | ||
})); | ||
@@ -41,0 +45,0 @@ // onVisibleRectChange must be called from an effect, not during render. |
@@ -26,9 +26,13 @@ import {Rect as $60423f92c7f9ad87$export$c79fc6492f3af13d} from "./Rect.module.js"; | ||
let [virtualizer] = (0, $3Fik3$useState)(()=>new (0, $38b9490c1cca8fc4$export$89be5a243e59c4b2)({ | ||
setVisibleRect (rect) { | ||
setVisibleRect(rect); | ||
visibleRectChanged.current = true; | ||
}, | ||
// TODO: should changing these invalidate the entire cache? | ||
renderView: opts.renderView, | ||
invalidate: setInvalidationContext | ||
collection: opts.collection, | ||
layout: opts.layout, | ||
delegate: { | ||
setVisibleRect (rect) { | ||
setVisibleRect(rect); | ||
visibleRectChanged.current = true; | ||
}, | ||
// TODO: should changing these invalidate the entire cache? | ||
renderView: opts.renderView, | ||
invalidate: setInvalidationContext | ||
} | ||
})); | ||
@@ -35,0 +39,0 @@ // onVisibleRectChange must be called from an effect, not during render. |
@@ -0,5 +1,5 @@ | ||
var $197a1781bd47f5b9$exports = require("./ReusableView.main.js"); | ||
var $abed55ea619a7a17$exports = require("./utils.main.js"); | ||
var $191a033606d4fda1$exports = require("./OverscanManager.main.js"); | ||
var $41b7691783731623$exports = require("./Rect.main.js"); | ||
var $197a1781bd47f5b9$exports = require("./ReusableView.main.js"); | ||
var $064492b79924894c$exports = require("./Size.main.js"); | ||
@@ -35,3 +35,3 @@ | ||
let layoutInfo = this.layout.getLayoutInfo(k); | ||
if (!layoutInfo) break; | ||
if (!layoutInfo || layoutInfo.parentKey == null) break; | ||
k = layoutInfo.parentKey; | ||
@@ -53,8 +53,10 @@ if (k === key) return true; | ||
_renderView(reusableView) { | ||
let { type: type, key: key, content: content } = reusableView.layoutInfo; | ||
reusableView.content = content || this.collection.getItem(key); | ||
reusableView.rendered = this._renderContent(type, reusableView.content); | ||
if (reusableView.layoutInfo) { | ||
let { type: type, key: key, content: content } = reusableView.layoutInfo; | ||
reusableView.content = content || this.collection.getItem(key); | ||
reusableView.rendered = this._renderContent(type, reusableView.content); | ||
} | ||
} | ||
_renderContent(type, content) { | ||
let cached = this._renderedContent.get(content); | ||
let cached = content != null ? this._renderedContent.get(content) : null; | ||
if (cached != null) return cached; | ||
@@ -129,3 +131,3 @@ let rendered = this.delegate.renderView(type, content); | ||
if (view.content !== item) { | ||
this._renderedContent.delete(view.content); | ||
if (view.content != null) this._renderedContent.delete(view.content); | ||
this._renderView(view); | ||
@@ -164,3 +166,3 @@ } | ||
} | ||
if (opts.layout !== this.layout) { | ||
if (opts.layout !== this.layout || this.layout.virtualizer !== this) { | ||
if (this.layout) this.layout.virtualizer = null; | ||
@@ -222,4 +224,6 @@ opts.layout.virtualizer = this; | ||
} | ||
constructor(delegate){ | ||
this.delegate = delegate; | ||
constructor(options){ | ||
this.delegate = options.delegate; | ||
this.collection = options.collection; | ||
this.layout = options.layout; | ||
this.contentSize = new (0, $064492b79924894c$exports.Size); | ||
@@ -230,5 +234,5 @@ this.visibleRect = new (0, $41b7691783731623$exports.Rect); | ||
this._renderedContent = new WeakMap(); | ||
this._rootView = new (0, $197a1781bd47f5b9$exports.ReusableView)(this); | ||
this._rootView = new (0, $197a1781bd47f5b9$exports.RootView)(this); | ||
this._isScrolling = false; | ||
this._invalidationContext = null; | ||
this._invalidationContext = {}; | ||
this._overscanManager = new (0, $191a033606d4fda1$exports.OverscanManager)(); | ||
@@ -235,0 +239,0 @@ } |
@@ -0,5 +1,5 @@ | ||
import {RootView as $ad1d98aa8f0c31b4$export$e21886a4eef6b29a} from "./ReusableView.module.js"; | ||
import {isSetEqual as $fc36f9a046a9ce79$export$a8d0d0c8d1c5df64} from "./utils.module.js"; | ||
import {OverscanManager as $364191b3decf3697$export$4455ee6afb38dcbb} from "./OverscanManager.module.js"; | ||
import {Rect as $60423f92c7f9ad87$export$c79fc6492f3af13d} from "./Rect.module.js"; | ||
import {ReusableView as $ad1d98aa8f0c31b4$export$1a5223887c560441} from "./ReusableView.module.js"; | ||
import {Size as $ee1bfa90a957fb8a$export$cb6da89c6af1a8ec} from "./Size.module.js"; | ||
@@ -29,3 +29,3 @@ | ||
let layoutInfo = this.layout.getLayoutInfo(k); | ||
if (!layoutInfo) break; | ||
if (!layoutInfo || layoutInfo.parentKey == null) break; | ||
k = layoutInfo.parentKey; | ||
@@ -47,8 +47,10 @@ if (k === key) return true; | ||
_renderView(reusableView) { | ||
let { type: type, key: key, content: content } = reusableView.layoutInfo; | ||
reusableView.content = content || this.collection.getItem(key); | ||
reusableView.rendered = this._renderContent(type, reusableView.content); | ||
if (reusableView.layoutInfo) { | ||
let { type: type, key: key, content: content } = reusableView.layoutInfo; | ||
reusableView.content = content || this.collection.getItem(key); | ||
reusableView.rendered = this._renderContent(type, reusableView.content); | ||
} | ||
} | ||
_renderContent(type, content) { | ||
let cached = this._renderedContent.get(content); | ||
let cached = content != null ? this._renderedContent.get(content) : null; | ||
if (cached != null) return cached; | ||
@@ -123,3 +125,3 @@ let rendered = this.delegate.renderView(type, content); | ||
if (view.content !== item) { | ||
this._renderedContent.delete(view.content); | ||
if (view.content != null) this._renderedContent.delete(view.content); | ||
this._renderView(view); | ||
@@ -158,3 +160,3 @@ } | ||
} | ||
if (opts.layout !== this.layout) { | ||
if (opts.layout !== this.layout || this.layout.virtualizer !== this) { | ||
if (this.layout) this.layout.virtualizer = null; | ||
@@ -216,4 +218,6 @@ opts.layout.virtualizer = this; | ||
} | ||
constructor(delegate){ | ||
this.delegate = delegate; | ||
constructor(options){ | ||
this.delegate = options.delegate; | ||
this.collection = options.collection; | ||
this.layout = options.layout; | ||
this.contentSize = new (0, $ee1bfa90a957fb8a$export$cb6da89c6af1a8ec); | ||
@@ -224,5 +228,5 @@ this.visibleRect = new (0, $60423f92c7f9ad87$export$c79fc6492f3af13d); | ||
this._renderedContent = new WeakMap(); | ||
this._rootView = new (0, $ad1d98aa8f0c31b4$export$1a5223887c560441)(this); | ||
this._rootView = new (0, $ad1d98aa8f0c31b4$export$e21886a4eef6b29a)(this); | ||
this._isScrolling = false; | ||
this._invalidationContext = null; | ||
this._invalidationContext = {}; | ||
this._overscanManager = new (0, $364191b3decf3697$export$4455ee6afb38dcbb)(); | ||
@@ -229,0 +233,0 @@ } |
{ | ||
"name": "@react-stately/virtualizer", | ||
"version": "3.0.0-nightly-0ddbe6f95-241021", | ||
"version": "3.0.0-nightly-10a43de88-241127", | ||
"description": "Spectrum UI components in React", | ||
@@ -25,8 +25,8 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@react-aria/utils": "^3.0.0-nightly-0ddbe6f95-241021", | ||
"@react-types/shared": "^3.0.0-nightly-0ddbe6f95-241021", | ||
"@react-aria/utils": "^3.0.0-nightly-10a43de88-241127", | ||
"@react-types/shared": "^3.0.0-nightly-10a43de88-241127", | ||
"@swc/helpers": "^0.5.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" | ||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" | ||
}, | ||
@@ -36,3 +36,3 @@ "publishConfig": { | ||
}, | ||
"stableVersion": "4.1.0" | ||
"stableVersion": "4.2.0" | ||
} |
@@ -35,3 +35,3 @@ /* | ||
/** The Virtualizer the layout is currently attached to. */ | ||
virtualizer: Virtualizer<T, any>; | ||
virtualizer: Virtualizer<T, any> | null = null; | ||
@@ -87,9 +87,9 @@ /** | ||
getItemRect(key: Key): Rect { | ||
return this.getLayoutInfo(key)?.rect; | ||
getItemRect(key: Key): Rect | null { | ||
return this.getLayoutInfo(key)?.rect ?? null; | ||
} | ||
getVisibleRect(): Rect { | ||
return this.virtualizer.visibleRect; | ||
return this.virtualizer!.visibleRect; | ||
} | ||
} |
@@ -31,5 +31,5 @@ /* | ||
/** The content currently being displayed by this view, set by the virtualizer. */ | ||
content: T; | ||
content: T | null; | ||
rendered: V; | ||
rendered: V | null; | ||
@@ -39,12 +39,14 @@ viewType: string; | ||
parent: ReusableView<T, V> | null; | ||
children: Set<ReusableView<T, V>>; | ||
reusableViews: Map<string, ReusableView<T, V>[]>; | ||
children: Set<ChildView<T, V>>; | ||
reusableViews: Map<string, ChildView<T, V>[]>; | ||
constructor(virtualizer: Virtualizer<T, V>) { | ||
constructor(virtualizer: Virtualizer<T, V>, viewType: string) { | ||
this.virtualizer = virtualizer; | ||
this.key = ++KEY; | ||
this.parent = null; | ||
this.viewType = viewType; | ||
this.children = new Set(); | ||
this.reusableViews = new Map(); | ||
this.layoutInfo = null; | ||
this.content = null; | ||
this.rendered = null; | ||
} | ||
@@ -67,12 +69,10 @@ | ||
let reusable = this.reusableViews.get(reuseType); | ||
let view = reusable?.length > 0 | ||
? reusable.shift() | ||
: new ReusableView<T, V>(this.virtualizer); | ||
let view = reusable && reusable.length > 0 | ||
? reusable.shift()! | ||
: new ChildView<T, V>(this.virtualizer, this, reuseType); | ||
view.viewType = reuseType; | ||
view.parent = this; | ||
return view; | ||
} | ||
reuseChild(child: ReusableView<T, V>) { | ||
reuseChild(child: ChildView<T, V>) { | ||
child.prepareForReuse(); | ||
@@ -87,1 +87,16 @@ let reusable = this.reusableViews.get(child.viewType); | ||
} | ||
export class RootView<T extends object, V> extends ReusableView<T, V> { | ||
constructor(virtualizer: Virtualizer<T, V>) { | ||
super(virtualizer, 'root'); | ||
} | ||
} | ||
export class ChildView<T extends object, V> extends ReusableView<T, V> { | ||
parent: ReusableView<T, V>; | ||
constructor(virtualizer: Virtualizer<T, V>, parent: ReusableView<T, V>, viewType: string) { | ||
super(virtualizer, viewType); | ||
this.parent = parent; | ||
} | ||
} |
@@ -27,3 +27,3 @@ /* | ||
setVisibleRect(rect: Rect): void, | ||
renderView(type: string, content: T): V, | ||
renderView(type: string, content: T | null): V, | ||
invalidate(ctx: InvalidationContext): void | ||
@@ -35,3 +35,3 @@ } | ||
collection: Collection<T>, | ||
persistedKeys?: Set<Key>, | ||
persistedKeys?: Set<Key> | null, | ||
visibleRect: Rect, | ||
@@ -38,0 +38,0 @@ invalidationContext: InvalidationContext, |
@@ -24,3 +24,3 @@ /* | ||
interface VirtualizerProps<T extends object, V, O> { | ||
renderView(type: string, content: T): V, | ||
renderView(type: string, content: T | null): V, | ||
layout: Layout<T>, | ||
@@ -49,9 +49,13 @@ collection: Collection<T>, | ||
let [virtualizer] = useState(() => new Virtualizer<T, V>({ | ||
setVisibleRect(rect) { | ||
setVisibleRect(rect); | ||
visibleRectChanged.current = true; | ||
}, | ||
// TODO: should changing these invalidate the entire cache? | ||
renderView: opts.renderView, | ||
invalidate: setInvalidationContext | ||
collection: opts.collection, | ||
layout: opts.layout, | ||
delegate: { | ||
setVisibleRect(rect) { | ||
setVisibleRect(rect); | ||
visibleRectChanged.current = true; | ||
}, | ||
// TODO: should changing these invalidate the entire cache? | ||
renderView: opts.renderView, | ||
invalidate: setInvalidationContext | ||
} | ||
})); | ||
@@ -58,0 +62,0 @@ |
@@ -13,2 +13,3 @@ /* | ||
import {ChildView, ReusableView, RootView} from './ReusableView'; | ||
import {Collection, Key} from '@react-types/shared'; | ||
@@ -22,5 +23,10 @@ import {InvalidationContext, Mutable, VirtualizerDelegate, VirtualizerRenderOptions} from './types'; | ||
import {Rect} from './Rect'; | ||
import {ReusableView} from './ReusableView'; | ||
import {Size} from './Size'; | ||
interface VirtualizerOptions<T extends object, V> { | ||
delegate: VirtualizerDelegate<T, V>, | ||
collection: Collection<T>, | ||
layout: Layout<T> | ||
} | ||
/** | ||
@@ -60,11 +66,13 @@ * The Virtualizer class renders a scrollable collection of data using customizable layouts. | ||
private _visibleViews: Map<Key, ReusableView<T, V>>; | ||
private _visibleViews: Map<Key, ChildView<T, V>>; | ||
private _renderedContent: WeakMap<T, V>; | ||
private _rootView: ReusableView<T, V>; | ||
private _rootView: RootView<T, V>; | ||
private _isScrolling: boolean; | ||
private _invalidationContext: InvalidationContext | null; | ||
private _invalidationContext: InvalidationContext; | ||
private _overscanManager: OverscanManager; | ||
constructor(delegate: VirtualizerDelegate<T, V>) { | ||
this.delegate = delegate; | ||
constructor(options: VirtualizerOptions<T, V>) { | ||
this.delegate = options.delegate; | ||
this.collection = options.collection; | ||
this.layout = options.layout; | ||
this.contentSize = new Size; | ||
@@ -75,5 +83,5 @@ this.visibleRect = new Rect; | ||
this._renderedContent = new WeakMap(); | ||
this._rootView = new ReusableView(this); | ||
this._rootView = new RootView(this); | ||
this._isScrolling = false; | ||
this._invalidationContext = null; | ||
this._invalidationContext = {}; | ||
this._overscanManager = new OverscanManager(); | ||
@@ -93,3 +101,3 @@ } | ||
let layoutInfo = this.layout.getLayoutInfo(k); | ||
if (!layoutInfo) { | ||
if (!layoutInfo || layoutInfo.parentKey == null) { | ||
break; | ||
@@ -113,3 +121,3 @@ } | ||
private getReusableView(layoutInfo: LayoutInfo): ReusableView<T, V> { | ||
private getReusableView(layoutInfo: LayoutInfo): ChildView<T, V> { | ||
let parentView = this.getParentView(layoutInfo)!; | ||
@@ -123,9 +131,11 @@ let view = parentView.getReusableView(layoutInfo.type); | ||
private _renderView(reusableView: ReusableView<T, V>) { | ||
let {type, key, content} = reusableView.layoutInfo; | ||
reusableView.content = content || this.collection.getItem(key); | ||
reusableView.rendered = this._renderContent(type, reusableView.content); | ||
if (reusableView.layoutInfo) { | ||
let {type, key, content} = reusableView.layoutInfo; | ||
reusableView.content = content || this.collection.getItem(key); | ||
reusableView.rendered = this._renderContent(type, reusableView.content); | ||
} | ||
} | ||
private _renderContent(type: string, content: T) { | ||
let cached = this._renderedContent.get(content); | ||
private _renderContent(type: string, content: T | null) { | ||
let cached = content != null ? this._renderedContent.get(content) : null; | ||
if (cached != null) { | ||
@@ -206,3 +216,3 @@ return cached; | ||
let removed = new Set<ReusableView<T, V>>(); | ||
let removed = new Set<ChildView<T, V>>(); | ||
for (let [key, view] of this._visibleViews) { | ||
@@ -230,3 +240,5 @@ let layoutInfo = visibleLayoutInfos.get(key); | ||
if (view.content !== item) { | ||
this._renderedContent.delete(view.content); | ||
if (view.content != null) { | ||
this._renderedContent.delete(view.content); | ||
} | ||
this._renderView(view); | ||
@@ -273,3 +285,3 @@ } | ||
if (opts.layout !== this.layout) { | ||
if (opts.layout !== this.layout || this.layout.virtualizer !== this) { | ||
if (this.layout) { | ||
@@ -276,0 +288,0 @@ this.layout.virtualizer = null; |
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
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
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
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
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
276679
3643