How to achieve virtual scrolling for contents using the ejScroller?
What is Virtual Scrolling?
The virtual scrolling is used to display the large amounts of records without paging. When scrolling with the vertical scrollbar, AJAX requests will be executed to load and refresh the existing records.
How to achieve this virtual scrolling?
We can achieve this virtual scrolling in ejScroller using our existing event “scroll” and method “refresh” of ejScroller.
“Scroll” event will be trigger at that time of scrolling and the refresh method used to refresh the vertical scrollbar handle based on height of the target area content.
When the scroll bar handle reaches its end points we can upload the data using AJAX request in scroll event. Also we need to call refresh methods to refresh the scroll bar based on current content (after new content loaded success fully).
Please refer the below code snippet
In this code, document.getElementsByClassName("sampleContent").scrollHeight-e.scrollTop > obj.option(“height”) is used to find whether the vertical scroll bar handle reaches is end points in scroll bar. When the handle is reaches its end points, we have loaded the data and then appends this to target pane of scroll bar.
Like this whenever the scroll bar’s vertical handle reaches its end points another new content will be loaded and this process will be continued until all the contents will get loaded successfully.
|Article ID:||Published Date:||Last Revised Date:||Platform:||Control:|