Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Virtualizer and WindowVirtualizer #303

Merged
merged 1 commit into from
Jan 7, 2024
Merged

Add Virtualizer and WindowVirtualizer #303

merged 1 commit into from
Jan 7, 2024

Conversation

inokawa
Copy link
Owner

@inokawa inokawa commented Dec 30, 2023

close #219
close #272
#284
#310

This PR will add new Virtualizer component and refactor VList to use it. And it will also change WVList to WindowVirtualizer(window scrolling version of Virtualizer).

Why?

This project was started to create an one-fit-all component for list virtualization. However soon I had noticed that list virtualization has varieties of use cases. Supporting both easy usage and complex usage in one component will increase complexity of code and bundle size, and will lose simplicity of API.

So this PR is a first step moving forward. We will keep VList as simple solution for many. Otherwise add Virtualizer to be customizable for advanced usage and composable with any markup/libraries. In the future, we will add more APIs to Virtualizer to controll virtualization at lower level.

@inokawa inokawa force-pushed the composable branch 23 times, most recently from 6808292 to 85b08ee Compare January 5, 2024 05:48
@inokawa inokawa marked this pull request as ready for review January 5, 2024 11:48
@inokawa inokawa marked this pull request as draft January 5, 2024 11:48
@inokawa inokawa marked this pull request as ready for review January 6, 2024 14:33
@inokawa inokawa merged commit facd068 into main Jan 7, 2024
3 checks passed
@inokawa inokawa deleted the composable branch January 7, 2024 11:36
@inokawa inokawa mentioned this pull request Jan 9, 2024
takecchi referenced this pull request in cuculus-dev/cuculus Jan 16, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [virtua](https://togithub.com/inokawa/virtua) | [`0.18.0` ->
`0.20.5`](https://renovatebot.com/diffs/npm/virtua/0.18.0/0.20.5) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/virtua/0.20.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/virtua/0.20.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/virtua/0.18.0/0.20.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/virtua/0.18.0/0.20.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

@coderabbitai: ignore

---

### Release Notes

<details>
<summary>inokawa/virtua (virtua)</summary>

### [`v0.20.5`](https://togithub.com/inokawa/virtua/releases/tag/0.20.5)

[Compare
Source](https://togithub.com/inokawa/virtua/compare/0.20.4...0.20.5)

#### What's Changed

- Fix wrong minHeight/minWidth of Vue VList by
[@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/325](https://togithub.com/inokawa/virtua/pull/325)

**Full Changelog**:
inokawa/virtua@0.20.4...0.20.5

### [`v0.20.4`](https://togithub.com/inokawa/virtua/releases/tag/0.20.4)

[Compare
Source](https://togithub.com/inokawa/virtua/compare/0.20.3...0.20.4)

#### What's Changed

- Fix swr minify issue in Next.js by
[@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/324](https://togithub.com/inokawa/virtua/pull/324)

**Full Changelog**:
inokawa/virtua@0.20.3...0.20.4

### [`v0.20.3`](https://togithub.com/inokawa/virtua/releases/tag/0.20.3)

[Compare
Source](https://togithub.com/inokawa/virtua/compare/0.20.2...0.20.3)

#### What's Changed

- Improve touch handling in WindowVirtualizer by
[@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/321](https://togithub.com/inokawa/virtua/pull/321)

**Full Changelog**:
inokawa/virtua@0.20.2...0.20.3

### [`v0.20.2`](https://togithub.com/inokawa/virtua/releases/tag/0.20.2)

[Compare
Source](https://togithub.com/inokawa/virtua/compare/0.20.1...0.20.2)

#### What's Changed

- Revert "Add `contain: content` to container element" by
[@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/318](https://togithub.com/inokawa/virtua/pull/318)

**Full Changelog**:
inokawa/virtua@0.20.1...0.20.2

### [`v0.20.1`](https://togithub.com/inokawa/virtua/releases/tag/0.20.1)

[Compare
Source](https://togithub.com/inokawa/virtua/compare/0.20.0...0.20.1)

#### What's Changed

- Ignore inappropriate flex style by
[@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/316](https://togithub.com/inokawa/virtua/pull/316)
- Update style of Vue VList to be the same as React by
[@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/317](https://togithub.com/inokawa/virtua/pull/317)

**Full Changelog**:
inokawa/virtua@0.20.0...0.20.1

### [`v0.20.0`](https://togithub.com/inokawa/virtua/releases/tag/0.20.0)

[Compare
Source](https://togithub.com/inokawa/virtua/compare/0.19.2...0.20.0)

#### BREAKING CHANGES

- Incomplete padding support was dropped from `VList`. Use `Virtualizer`
and `startMargin`/`endMargin` prop instead.

```tsx
// VList
<VList style={{ paddingTop:20, paddingBottom: 40 }}>
 {createRows(1000)}
</VList>

// Virtualizer
<div style={{ overflowY: 'auto', overflowAnchor: "none" }}>
  <div style={{ height: 20 }}/>
  <Virtualizer startMargin={20} endMargin={40}>
   {createRows(1000)}
  </Virtualizer>
  <div style={{ height: 40 }}/>
</div>
```

- `components.Root` prop of `VList` was removed. Use `Virtualizer`
instead. If you want to customize scrollable element, just pass props to
wrapper div. If you want to customize inner element, use `as` prop of
`Virtualizer`.

```tsx
// VList
<VList components={{ Root: ViewportComponent }}>
 {createRows(1000)}
</VList>

// Virtualizer
<div style={{ overflowY: 'auto' }}>
  <Virtualizer as={ContainerComponent}>
   {createRows(1000)}
  </Virtualizer>
</div>
```

- `WVList` was renamed and changed to `WindowVirtualizer` because it has
similar usability to `Virtualizer`. It's wrapper div was removed so add
it by yourself if you need to apply some styles.

```tsx
// WVList
<div style={{ padding: 200 }}>
  <WVList style={{ border: "solid 1px gray" }}>
   {createRows(1000)}
  </WVList>
</div>

// WindowVirtualizer
<div style={{ padding: 200 }}>
  <div style={{ border: "solid 1px gray" }}>
    <WindowVirtualizer>{createRows(1000)}</WindowVirtualizer>
  </div>
</div>
```

-   `components.Item` prop of `VList` was renamed to `item`
-   `initialItemSize` prop was renamed to `itemSize`
-   `onScrollStop` prop was renamed to `onScrollEnd`

#### What's Changed

- Add Virtualizer and WindowVirtualizer by
[@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/303](https://togithub.com/inokawa/virtua/pull/303)

**Full Changelog**:
inokawa/virtua@0.19.2...0.20.0

### [`v0.19.2`](https://togithub.com/inokawa/virtua/releases/tag/0.19.2)

[Compare
Source](https://togithub.com/inokawa/virtua/compare/0.19.1...0.19.2)

#### What's Changed

- Fix bug that scrollOffset can become minus by filtering after
scrolling by [@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/314](https://togithub.com/inokawa/virtua/pull/314)

**Full Changelog**:
inokawa/virtua@0.19.1...0.19.2

### [`v0.19.1`](https://togithub.com/inokawa/virtua/releases/tag/0.19.1)

[Compare
Source](https://togithub.com/inokawa/virtua/compare/0.19.0...0.19.1)

#### What's Changed

- Improve jump compensation after prepending by
[@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/313](https://togithub.com/inokawa/virtua/pull/313)

**Full Changelog**:
inokawa/virtua@0.19.0...0.19.1

### [`v0.19.0`](https://togithub.com/inokawa/virtua/releases/tag/0.19.0)

[Compare
Source](https://togithub.com/inokawa/virtua/compare/0.18.1...0.19.0)

- **BREAKING**: `initialItemCount` prop was renamed to `ssrCount` and
now only for SSR

#### What's Changed

- Remove hidden style from items in SSR before hydration by
[@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/309](https://togithub.com/inokawa/virtua/pull/309)

**Full Changelog**:
inokawa/virtua@0.18.1...0.19.0

### [`v0.18.1`](https://togithub.com/inokawa/virtua/releases/tag/0.18.1)

[Compare
Source](https://togithub.com/inokawa/virtua/compare/0.18.0...0.18.1)

#### What's Changed

- Refactor cache by [@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/294](https://togithub.com/inokawa/virtua/pull/294)
- Add docs for Vue by [@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/295](https://togithub.com/inokawa/virtua/pull/295)
- Refactor resizer by [@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/300](https://togithub.com/inokawa/virtua/pull/300)
- Use Vue JSX by [@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/302](https://togithub.com/inokawa/virtua/pull/302)
- Add `contain: content` to container element by
[@&#8203;inokawa](https://togithub.com/inokawa) in
[https://github.com/inokawa/virtua/pull/308](https://togithub.com/inokawa/virtua/pull/308)

**Full Changelog**:
inokawa/virtua@0.18.0...0.18.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/cuculus-dev/cuculus).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEyNy4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: takecchi <takecchi.kobayashi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Padding is buggy Seek better API to override components
1 participant