rocwang / vue-virtual-scroll-grid

A Vue 3 component that can render a list with 1000+ items as a grid in a performant way.
https://grid.kiwiberry.nz/
MIT License
300 stars 31 forks source link

[FEATURE REQUEST] enhance `scrollTo` prop if put Grid in a `overflow: auto` element #182

Closed hunterliu1003 closed 2 years ago

hunterliu1003 commented 2 years ago

In my use case, I put a Grid component in a overflow: auto element, then the prop scrollTo not working

<div style="height: 300px; overflow: auto">
  <Grid ... scrollTo="activeIndex">...</Grid>
</div>

I think the reason is the prop scrollTo is implemented with window.scrollTo.

Grid.vue: L114-L120

onUpdated(
  once(() => {
    windowScrollTo$.subscribe((next) => {
      window.scrollTo({ top: next, behavior: "smooth" });
    });
  })
);

Do you have any ideas or solutions to improve the scrollTo with my use case?

rocwang commented 2 years ago

I think it should be possible by replacing window with the grid container.

hunterliu1003 commented 2 years ago

Do you plan to add this functionality?

Btw, I send you one time sponsorship for this great component and your hard work. Thanks

rocwang commented 2 years ago

I'll take a look this weekend. Thanks for the sponsorship! 👍

rocwang commented 2 years ago

@hunterliu1003

This is supported in v1.4.0 now. Let me know if you have any problem with it.

hunterliu1003 commented 2 years ago

@rocwang

It just worked like a charm. Thank you for implementing this feature soooooo fast!