-
Fixed React
18.2.0
bug in "strict" mode whenuseInsertionEffect()
doesn't run twice on mount unlikeuseEffect()
oruseLayoutEffect()
. -
Fixed React
18.2.0
bug when out-of-sync (stale) state values are being rendered.
- Renamed
onItemHeightChange()
toonItemHeightDidChange()
.
-
Added a new property on
<VirtualScroller/>
—getInitialItemState(item)
. The same option was added inVirtualScroller
constructor parameters. -
Deprecated
itemIndex
property ofitemComponent
. The rationale is that setting newitems
on a React component is an asynchronous operation, so when a user obtainsitemIndex
, they don't know whichitems
list does that index correspond to, therefore making it useless, or even buggy if used incorreclty. -
(React) Renamed
itemComponent
'sonStateChange()
property tosetState()
. The older property name still works but is considered deprecated. -
Renamed
VirtualScroller
'sonItemStateChange()
instance method tosetItemState()
. The older instance method name still works but is considered deprecated. -
(TypeScript) Added a new (second or third) "generic" parameter (interface) called
ItemState
which isundefined
by default. Removed the previously exported type calledItemState
which was defined asany | undefined
.- (React) The addition of the new "generic" parameter has changed the order of generic parameters in the
<VirtualScroller/>
React component from<Item, ItemComponentProps, AsElement>
to<ItemComponentProps, Item, ItemState, AsElement>
.
- (React) The addition of the new "generic" parameter has changed the order of generic parameters in the
-
(miscellaneous) In README, when describing
VirtualScroller
state,itemStates
anditemHeights
properties were previously marked as "optional" for some unknown reason. They've been properly marked as "required" now.
-
Add a fix for calculating the initial state when using
getScrollableContainer
on the React component of<VirtualScroller/>
. Previously, it threw an error when it found that the scrollable container element hasn't been mounted by the time<VirtualScroller/>
element started being rendered (just rendered, not mounted yet). Now it falls back to some sensible default values for the size of the scrollable container until the<VirtualScroller/>
element has been mounted on a page. -
Renamed
estimatedItemHeight
parameter togetEstimatedItemHeight()
. The older parameter name still works but is deprecated. -
Added
getEstimatedVisibleItemRowsCount()
parameter. It can be used instead ofgetEstimatedItemHeight()
.
-
[React] Applied TypeScript props fixes.
-
[React] Added two new properties:
item
anditemIndex
. The legacychildren
property is still passed but is considered deprecated.
General changes:
-
Refactored the code.
-
Moved to "ES Modules" exports (
type: "module"
). It's supposed to be a non-breaking change.
Changes to the React component:
-
Rewrote React
<VirtualScroller/>
component as a function instead of aComponent
class. -
Supposedly fixed re-mounting of the React component in accordance with React's recent change when they demand a component be mountable and unmountable several times during its lifetime.
-
Un-deprecated
getScrollableContainer()
option. It can be used instead ofscrollableContainer
option. The reason is React's recent change when they demand a component be mountable and unmountable several times during its lifetime: in that case, if components get mounted and unmounted several times, thescrollableContainer
DOM Element reference does change between those re-mounts, so simply passing ascrollableContainer
option would end up pointing to a non-existent DOM element on re-mount because the "core" (low-level)VirtualScroller
class doesn't get re-created on re-mount. -
(advanced) (breaking change) Removed the
initialCustomState
property due to not being used. -
(advanced) (breaking change) Removed
.renderItem(i)
instance method from React<VirtualScroller/>
component.
(advanced) Changes to the "core" (low-level) VirtualScroller
class:
-
Renamed
.listen()
instance method ofVirtualScroller
to.start()
. -
(breaking change) Removed long-deprecated instance methods:
.layout()
— use.updateLayout()
instead..onMount()
— use.start()
instead..render()
— use.start()
instead..listen()
— use.start()
instead..onUnmount()
— use.stop()
instead..onUnmount()
— use.destroy()
instead..updateItems()
— use.setItems()
instead.
-
(breaking change) Removed the
customState
option due to not being used. -
(breaking change)
onStateChange()
function used to receive two parameters:newState
andpreviousState
. Now it only receives one parameter:newState
. Also, previously the readme adviced to perform a re-rendering of the list inonStateChange()
. That's no longer true andonStateChange()
should only be used for keeping track of theVirtualScroller
state. For rendering there's a new parameter function calledrender()
. -
(breaking change) When not using custom (external) state management, passing a
render()
function as an option is required now. Therender()
function should (re)render the list.
(advanced) Changes to the "core" (low-level) VirtualScroller
class when using custom (external) state management:
-
(advanced) (breaking change) Removed
getState
/setState
options of theVirtualScroller
class. Instead, there's a new instance method called.useState()
that should be called withgetState
andupdateState
parameters for enabling custom (external) state management. See the readme for more details. -
(breaking change) A custom
setState()
state updater function ofVirtualScroller
used to receive awillUpdateState()
parameter. That parameter has been removed now due to no longer being used. -
(breaking change) A custom
setState()
state updater function ofVirtualScroller
previously received adidUpdateState(prevState)
parameter function that should have been called on every state update. That parameter function has been removed. Instead, call a new instance method ofVirtualScroller
:virtualScroller.onRender()
(without any arguments). -
(breaking change) Renamed the custom
setState()
state updater function toupdateState()
. -
(breaking change) The old
setState()
state updater function was called also when setting the initial state. The newupdateState()
state updater function doesn't get called to set the initial state. Instead, aVirtualScroller
instance provides a.getInitialState()
method, and developers are supposed to set the initial external state value themselves.
(advanced) Changes to custom rendering Engine
s:
- (breaking change) Changed
Engine
interface:createScrollableContainer()
function now receivesgetScrollableContainer()
as its first argument instead ofscrollableContainer
. The reason is React's recent change when they demand a component be mountable and unmountable several times throughout its lifetime: in that case, if components get mounted and unmounted several times, thescrollableContainer
DOM Element reference does change between those re-mounts, so simply passing ascrollableContainer
option would end up pointing to a non-existent DOM element on re-mount because the "core" (low-level)VirtualScroller
class doesn't get re-created on re-mount.re-mounts.
-
Refactored the code. Some parts got rewritten.
-
Added tests.
-
Added TypeScript "typings" (didn't check).
-
Fixed the list being reset on resize.
-
Removed
preserveScrollPositionOfTheBottomOfTheListOnMount
option because it's not used.
- Fixed the fix of
.scrollTo()
in IE 11.
- Fixed
.scrollTo()
in IE 11. The fix was suggested by Patrik Prevužňák.
- Fixed
ReferenceError: firstShownItemIndex is not defined
in cases whenitems
list has changed and the prepended items count is not a multiple of the columns count.
-
Removed
scrollY
fromVirtualScroller
'sstate
: instead, passinitialScrollPosition
andonScrollPositionChange()
options toVirtualScroller
constructor (or the same properties to the React component). -
Removed
getItemCoordinates(i)
function. -
Added
engine
option. -
Refactored.
-
Removed
shouldUpdateLayoutOnWindowResize
function. -
Refactored DOM stuff into
ScrollableContainer.js
andScreen.js
.
- React
<VirtualScroller/>
.renderItem(i)
now supports passing item object itself as an argument.
-
Refactored code a bit, wrote some comments.
-
Fixed a small layout calculation bug when there're several
onItemHeightChange(i)
calls made at the same time.
-
Removed
getItemKey(item)
property of React<VirtualScroller/>
. UsegetItemId(item)
option ofVirtualScroller
instead. -
Added
getItemId(item)
option ofVirtualScroller
.
- Added
getItemKey(item)
property of React<VirtualScroller/>
: that fixes forced re-rendering of all visible items wheneveritems
property changes.
- Fixed measuring item vertical spacing.
- Fixed
VirtualScroller
re-rendering itself from scratch when calling.setItems()
with no new items.
-
Added support for multiple columns.
-
Fixed
shouldUpdateLayoutOnWindowResize()
bug when theVirtualScroller
didn't rerender on window resize. -
Fixed
preserveScrollPositionOfTheBottomOfTheListOnMount
bug when it incorrectly calculated the new scroll position.
-
Renamed
.onMount()
/.render()
instance method to.listen()
. The older method name still works. -
Renamed
.onUnmount()
/.destroy()
instance method to.stop()
. The older method name still works.
-
(unlikely breaking change) If custom
setState
is defined, then it must call twoVirtualScroller
's instance methods:.willUpdateState(newState, prevState)
and.didUpdateState(prevState)
. This is unlikely to break anyone's code because it's unlikely that someone implemented their ownVirtualScroller
rather than using the provided/dom
or/react
ones. -
(unlikely breaking change) Removed
.onUpdate(prevState)
instance method ofVirtualScroller
: it has been superceded by.didUpdateState(prevState)
. This is unlikely to break anyone's code because it's unlikely that someone implemented their ownVirtualScroller
rather than using the provided/dom
or/react
ones. -
(unlikely breaking change)
setState(newState)
option function no longer receives the secondcallback
argument (instead, the argument is an object now). This is unlikely to break anyone's code because it's unlikely that someone implemented their ownVirtualScroller
rather than using the provided/dom
or/react
ones. -
Fixed "window is not defined" error on server side.
-
Renamed
.onMount()
instance method to.render()
. The older method name still works. -
Renamed
.onUnmount()
instance method to.destroy()
. The older method name still works. -
Renamed
preserveScrollPositionAtBottomOnMount
option/property topreserveScrollPositionOfTheBottomOfTheListOnMount
. -
Deprecated
onItemFirstRender(i)
. AddedonItemInitialRender(item)
as a replacement. The reason is thatitem
is more consistent thani
which can be non-consistent with theitems
passed to<VirtualScroller/>
in React due tosetState()
not being instanteneous: when newitems
are passed to<VirtualScroller/>
,VirtualScroller.setState({ items })
is called, and ifonItemFirstRender(i)
is called after the aforementionedsetState()
is called but before it finishes,i
would point to an index in "previous"items
while the application would assume thati
points to an index in the "new"items
, resulting in an incorrect item being assumed by the application or even in an "array index out of bounds" error.
- Fixed Chrome's
setTimeout()
delay lag bug by usingrequestAnimationFrame()
.
- An experimental
getScrollableContainer()
option has been changed to justscrollableContainer
.
- Added an experimental
getScrollableContainer()
option that supports renderingVirtualScroller
somewhere in a scrollable ancestor.
-
Fixed an infinite initial render loop in
DOMVirtualScroller
. -
It turned out that rendering items as
<tr/>
s inside a<tbody/>
didn't work because a<tbody/>
can't havepadding
. A workaround has been added that involves CSS variables which aren't supported in Internet Explorer: in such case,VirtualScroller
renders in "bypass" mode (render all items).
-
Added
onItemUnmount
option on DOMVirtualScroller
: it's called when aVirtualScroller
item DOMElement
is unmounted. Can be used to add DOMElement
"pooling". -
Deprecated
onMount
option.
-
state.scrollY
is now applied on mount: if initialstate
is passed, then the page will be scrolled tostate.scrollY
onVirtualScroller
mount. -
Documented
bypass: boolean
property/option. Can be used on server side to render the full list of items (for example, search engine indexing).
- Added
scrollY
inVirtualScroller
state.
- Added
<VirtualScroller/>
as
property.
-
Fixed
VirtualScroller
not rendering more thanmeasureItemsBatchSize
items. -
Fixed
VirtualScroller
performing a re-layout on enter/exit fullscreen. -
Added
shouldUpdateLayoutOnWindowResize(event)
option / property to prevent re-layout on some windowresize
events. Theresize
event is not only triggered when a user resizes the window itself: it's also triggered when the user switches into (and out of) fullscreen mode. By default,VirtualScroller
performs a re-layout on all windowresize
events, except for ones that don't result in actual window width or height change, and except for cases when, for example, a video somewhere in a list is maximized into fullscreen. There still can be other "custom" cases: for example, when an application uses a custom "slideshow" component (rendered outside of the list DOM element) that goes into fullscreen when a user clicks a picture or a video in the list. For such "custom" casesshouldUpdateLayoutOnWindowResize(event)
option / property can be specified. -
Renamed
VirtualScroller.layout()
toVirtualScroller.updateLayout()
. The old method name still works but is considered deprecated. -
Replaced
throttle
withdebounce
on windowresize
.
-
Renamed
VirtualScroller.updateItems()
toVirtualScroller.setItems()
. The old method name still works but is considered deprecated. -
Renamed
ReactVirtualScroller.updateItem(i)
toReactVirtualScroller.renderItem(i)
. The old method name still works but is considered deprecated. -
Renamed
preserveScrollPosition
option/property topreserveScrollPositionOnPrependItems
. The old option/property name still works but is considered deprecated. -
Added
preserveScrollPositionAtBottomOnMount: boolean
option/property.
-
Added
.getItemCoordinates(i)
instance method. -
Fixed
preserveScrollPosition
(previously it could measure the change in document height incorrectly). -
Fixed re-layout on window resize.
- Added
preserveScrollPosition: boolean
option toVirtualScroller.updateItems(newItems, [options])
and the correspondingpreserveScrollPosition: boolean
property to<ReactVirtualScroller/>
. Previously, when prepending items it would automatically preserve scroll position. Turned out that it might not always be the desired behavior. For example, when displaying live search results via<VirtualScroller/>
as the user types the search query: in such cases erasing a character at the end of the search query could result in "prepending" an item to the search results that would in turn result in scroll position changing due to being "auto-preserved" which is not what a user would expect. Now the "preserve scroll position on prepending items" feature is only active when explicitly enabled via thepreserveScrollPosition: boolean
option/property.
- Removed
onLastSeenItemIndexChange(newIndex, prevIndex)
option, useonItemFirstRender(i)
option instead.