Given a list of items, only render what's visible on the screen while allowing scrolling the whole list.

Overview

Solid Windowed

Given a list of items, only render what's visible on the screen while allowing scrolling the whole list.

A Solid component. See https://www.solidjs.com/

Usage

Use in the same way as a solid For. Please see: https://www.solidjs.com/docs/latest/api

import Windowed from 'solid-windowed'

let list = []
for (let i = 0; i < 250_000; i++) list.push(i)

export default function YourComponent() {
	return (
		<div style="height:100%;">
			<Windowed each={list}>
				{(value, index) => {
					return (
						<div>
							Index in list is {index}, value is: {value}
						</div>
					)
				}}
			</Windowed>
		</div>
	)
}

Install

npm install https://github.com/titoBouzout/solid-windowed.git

or

npm install solid-windowed

How it works?

It renders the first 10 elements of the list, then averages the height and with that in mind, we get the height of the container and render N items. As you scroll we slice the list to show what's supposed to be visible. If our average didn't fill the whole available space, we will add more items till its filled.

Caveats

  • You are responsible for setting the height of the container item. Child will be 100%

Alternatives

I started this project without knowing there was already an implementation of this concept

Bugs That Have Been Fixed

The end of the list, seems to be a problematic edge case for the implementation of this concept.

  • scrolling to the bottom doesn't render the last few items
  • when at the bottom of the list and then maximising to a bigger size, doesn't render previous items

Author

URL

You might also like...

A single-page application that allow users to add their To Do items. The items could be checked as completed and the completed task can be removed. Built with JavaScript, HTML and CSS

To Do list Application This is a single page application that allows users to keep track of their tasks. Users can add the task and also check the che

Oct 14, 2022

Share your screen to a projector with only a web-browser.

Share your screen to a projector with only a web-browser.

picklecast - Simple Screen Cast Receiver Screen share to a RaspberryPi or display computer connected to a projector or TV. Quickstart Install and star

Nov 17, 2022

Chrome extension that applies phrase-based line breaking and visible phrase boundaries to the current page.

Chrome extension that applies phrase-based line breaking and visible phrase boundaries to the current page.

BudouX Chrome Extension This extension applies the phrase-based line breaking or the Japanese Wakachi-gaki style line breaking to the current page. Pl

Nov 18, 2022

Catalogist is the easy way to catalog and make your software and (micro)services visible to your organization in a lightweight and developer-friendly way.

Catalogist is the easy way to catalog and make your software and (micro)services visible to your organization in a lightweight and developer-friendly way.

catalogist 📚 📓 📒 📖 🔖 The easy way to catalog and make your software and (micro)services visible to your organization through an API You were a pe

Dec 13, 2022

Lazyload images, iframes or any src* element until they are visible in the viewport.

Lazyload images, iframes or any src* element until they are visible in the viewport.

Nov 15, 2022

A website that acts as a guide about the universities to potential students whole throughout the globe.

A website that acts as a guide about the universities to potential students whole throughout the globe.

Apr 15, 2022

Open the whole new fancy chapter, in which end-user can interact lively with our quests!

Open the whole new fancy chapter, in which end-user can interact lively with our quests!

Fancy Chapter - Here comes the fancy adventure! Fancy Chapter is the User Interface (UI) of TheNewsQuest app, in which user can freely interact tons o

Aug 5, 2022

we learn the whole concept of JS including Basics like Object, Functions, Array etc. And Advance JS - Understanding DOMs, JQuery, Ajax, Prototypes etc.

JavaScript-for-Complete-Web Development. we learn the whole concept of JS including Basics like Object, Functions, Array etc. And Advance JS - Underst

Jul 22, 2022

Get started with GatsbyJS straight away without having to spend a whole day configuring your usual addons.

Get started with GatsbyJS straight away without having to spend a whole day configuring your usual addons.

Gatsby Starter Infinite Get started with GatsbyJS straight away without having to spend a whole day configuring your usual addons. This starter includ

Jun 27, 2022
Comments
  • When using HTML5 (`<!DOCTYPE html>`), solid-windowed requires that html/body have height set to 100%

    When using HTML5 (``), solid-windowed requires that html/body have height set to 100%

    Thanks for sharing your library. I think it fits my current project well.

    It seems like Windowed requires this styling, when it's used in an HTML5 document:

    html, body {
        height: 100%;
    }
    

    I realized that this issue may not be apparent in Solid Playground, because there are base styles there, including html, body { height: 100% }.

    What happens without it? Well, it can be a blank page. What surprised me at first is that there were no elements being rendered by the <For> loop inside <Windowed>, in my local code... until I removed <!DOCTYPE html> from my index.html! I think it's because solid-windowed's calculations were deciding to render zero elements.


    Thinking about a solution: maybe just adding a note to the README with that chunk of CSS?

    opened by floer32 1
  • Playground issue

    Playground issue

    Playground example https://playground.solidjs.com/?hash=-1161667584&version=1.3.7 doesn't load.

    Displays error

    /main.tsx: A numeric separator is only allowed between two digits. (10:23)
    
    8 | // lets render a list with 1 and a half million of items
    9 | let list = [];
    > 10 | for (let i = 0; i < 1_500_000; i++) list.push(i);
    | ^
    11 |
    12 | return (
    13 | <div style="height:100%;">
    
    opened by aquaductape 1
Owner
Tito
Tito
adds the *scrollin* and *scrollout* events to jquery, which will fire when any given element becomes (respectively) visible and invisible in the browser viewpori

jQuery.scrolling This plugin adds the scrollin and scrollout events to jquery: these events will fire when any given element becomes visible/invisible

Dark 5 Apr 7, 2021
The awesomebooks project is a simple list, but separated into 3 parts and given a retro feel. The main page is where we can add books, and on another page we can see the list, and remove items. There is also a "contact-us" page.

Awesome Books This is the restructured version of the famous awesome-books project! Here you can find JavaScript broken into modules, using import-exp

Matt Gombos 12 Nov 15, 2022
A mod for Mindustry that adds a few items and liquids, and a whole new tier of upgrades, along with arc

A mod that adds a few items and liquids, and a whole new tier of upgrades, along with arc. Made by Chickenloser and Oreo with help from Duvent.

null 5 Nov 25, 2022
BookStore is a website that allows a given user to view a list of books, to add a new book and remove a given book.

Project Name : BookStore CMS BookStore is a website that allows a given user to view a list of books, to add a new book and remove a given book. In or

Chris Siku 10 Aug 22, 2022
This project is a web app that uses the TVmaze API to retrieve data and display a list of items on the screen.

This project is a web app that uses the TVmaze API to retrieve data and display a list of items on the screen. It also enables people to like and comment on the broadcast. JavaScript, API, Bootstrap, HTML, and CSS3 were used to create this site.

Mihreteab Misganaw 2 Jan 10, 2022
This tool uses native browser APIs to take screenshots of a given web page, tab, window, or the user's entire screen.

This tool uses native browser APIs to take screenshots of a given web page, tab, window, or the user's entire screen.

xataio 761 Jan 1, 2023
The app helps you to add todo items to your list, mark completed ones and also delete finished items. Its a handy tool for your day today activies. Check out the live demo.

Todo List App The app helps you to add todo items to your list, mark completed ones and also delete finished items. Its a handy tool for your day toda

Atugonza ( Billions ) Joel 14 Apr 22, 2022
Smooth scrolling effect (while using mouse wheel). No jQuery or other unnecessary stuff needed.

scrooth Smooth scrolling effect (while using mouse wheel). No jQuery or other unnecessary stuff needed. Why? I needed that, and I was unable to find p

Rafał Spiżewski 20 Aug 29, 2022
A Zotero add-on that scans your Markdown reading notes, tags the associated Zotero items, and lets you open notes for the Zotero items in Obsidian.

Zotero Obsidian Citations Adds colored tags to Zotero items that have associated Markdown notes stored in an external folder. Open an associated Markd

Dae 210 Jan 4, 2023
A secondhand marketplace where you can post items for sale, interact with sellers, save items you are interested in.

Curbside - the secondhand market place that's actually pleasant to use Post items for sale, interact with sellers, save items you are interested in. A

Curbside 14 Sep 9, 2022