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

feat(useVirtualList): horizontal list #2310

Merged
merged 5 commits into from Oct 25, 2022

Conversation

Surof1n
Copy link
Contributor

@Surof1n Surof1n commented Oct 10, 2022

Description

add horizontal scroll to useVirtualList, fixes #2285

Additional context

I would like to know if I was moving in the right direction for a solution. Thanks

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@Surof1n
Copy link
Contributor Author

Surof1n commented Oct 10, 2022

The only question is maybe we don't should set display: flex on the container, but then the developer needs to manually create horizontal scrolling.

@Surof1n
Copy link
Contributor Author

Surof1n commented Oct 19, 2022

@antfu Hello, sorry for the link, can you tell me if this PR can be expected to be verified, or is something else needed?

Comment on lines +313 to +318
calculateRange,
scrollTo,
containerProps: {
ref: containerRef,
onScroll: () => {
calculateRange()
},
style: containerStyle,
},
containerStyle,
wrapperProps,
currentList,
containerRef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return types seems introduce a breaking change, is it intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at this feature, you will notice that there are no breaking changes.

export function useVirtualList <T = any>(list: MaybeRef<T[]>, options: UseVirtualListOptions): UseVirtualListReturn<T> {
  const { containerStyle, wrapperProps, scrollTo, calculateRange, currentList, containerRef } = 'itemHeight' in options
    ? useVerticalVirtualList(options, list)
    : useHorizontalVirtualList(options, list)

  return {
    list: currentList,
    scrollTo,
    containerProps: {
      ref: containerRef,
      onScroll: () => {
        calculateRange()
      },
      style: containerStyle,
    },
    wrapperProps,
  }
}

The original function still returns the same object as before.

It's just that the object has different values ​​depending on the direction of the list passed, but nothing has changed for the vertical sheet.

@antfu antfu merged commit bcedacd into vueuse:main Oct 25, 2022
@Surof1n Surof1n deleted the feature/horizontal-virtual-list branch October 25, 2022 22:28
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.

horizontal useVirtualList
2 participants