11. Scrolling
TargetJS supports two types of scrolling: window scrolling and custom scrolling, especially when you want to build your own scrolling interface.
Window scrolling is enabled by adding the onWindowScroll target. You can either set it to true or provide a function handler to listen for scroll events.
By default, TargetJS inserts a tree structure to optimize rendering long lists of items. This behavior is controlled by bracketThreshold, which is set to 40 by default. Once the list grows beyond 40 items, the tree structure is inserted.
TargetJS also keeps the DOM only for visible items. If you want to keep the DOM for all items, you can set either isVisible
or canDomDeleted to true on the container. This setting will be passed down to the items,
but it can also be overridden by each item individually.
The same example above can also be written using a custom scroll handler.