Better Rendering Performance with Virtual Lists

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ย. 2024
  • GO TRY OUT STORYBLOK!!! go.learnvue.co...
    RESOURCES
    DEMO - demos.learnvue...
    useVirtualList - vueuse.org/core/useVirtualList/
    useInfiniteScroll - vueuse.org/cor...
    ✅ Join the LearnVue+ Waiting List - learnvue.co
    Get early access to videos, exclusive content, interactive code challenges, and more.
    follow me on twitter:
    / mattmaribojoc
    🚨 Like quick Vue lessons like these? Check out 800+ lessons over on Vue School - go.learnvue.co...
    MUSIC
    Lukrembo - Animal Friends • lukrembo - animal frie...
    Lukrembo - Apricity • (no copyright music) l...
    Lukrembo - Bake a Pie • lukrembo - bake a pie ...
    Lukrembo - Bored • lukrembo - bored (roya...
    Lukrembo - Branch • (no copyright music) c...
    Lukrembo - Bread • (no copyright music) j...
    Lukrembo - Castle • lukrembo - castle (roy...
    Lukrembo - Daily • (no copyright music) c...
    Lukrembo - Forest • (no copyright music) l...
    Lukrembo - Home • lukrembo - home (royal...
    Lukrembo - I Always Love You • (no copyright music) l...
    Lukrembo - Imagine • (no copyright music) c...
    Lukrembo - Lamp • lukrembo - lamp (royal...
    Lukrembo - Marshmallow • lukrembo - marshmallow...
    Lukrembo - Night • lukrembo - night (roya...
    Lukrembo - Pancake • lukrembo - pancake (ro...
    Lukrembo - Picnic • lukrembo - picnic (roy...
    Lukrembo - Storybook • lukrembo - storybook (...
    Lukrembo - Together • lukrembo - together (r...
    Lukrembo - Wine • lukrembo - wine (royal...
    Lukrembo - Boba Tea • lukrembo - boba tea (r...
    #vuejs #vue #javascript #webdev

ความคิดเห็น • 90

  • @LearnVue
    @LearnVue  ปีที่แล้ว +25

    Shoot. A lot of yall have mentioned this so it's definitely something I should've included in the video, but.
    The itemHeight property can also be a function if your elements have different heights. For example,
    {
    itemHeight: (index) => index % 2 === 0 ? 500 : 1000
    }
    This still doesn't answer the question yall have about accepting variable text lengths and converting that to heights and tbh I haven't found out a solution that I like for that yet...So if you have ideas, drop a comment

    • @AkshaySood1
      @AkshaySood1 ปีที่แล้ว +1

      Was about to ask the same thing! 😅

    • @JulienReszka
      @JulienReszka ปีที่แล้ว

      Yea variable height would be a must for example in a list of chat messages

    • @supram941g5
      @supram941g5 ปีที่แล้ว +4

      use DynamicScroller from Akryum
      vue-virtual-scroller

  • @jingzheshan
    @jingzheshan ปีที่แล้ว +44

    What happens if the individual item has a random height?

  • @AdarshMadrecha
    @AdarshMadrecha ปีที่แล้ว +29

    These kind of step by step tutorials are realy helpful. Keep it up. Awesome content 👍🏻🤠

    • @LearnVue
      @LearnVue  ปีที่แล้ว +4

      glad to hear! i want to make both conceptual videos, but also more specific tutorials!

  • @soviut303
    @soviut303 ปีที่แล้ว +7

    Great tutorial. I'll be using this in an upcoming project. One thing I'd like to have seen covered is whether the virtual list can handle variable height content. For example, not every tweet is the same height.

    • @LearnVue
      @LearnVue  ปีที่แล้ว +5

      yeah definitely something i want to do too. i'm still looking for the best way to calculate height from the text. but useVirtualList's itemHeight can accept a function like (index) => number so trying to start there.

  • @isidorenwaiwu2793
    @isidorenwaiwu2793 ปีที่แล้ว +1

    The algorithm triumphs or am I been monitored😅😅. I am currently building a project at this very moment, where this feature is exactly what I need (14hrs after the video upload).
    I just am currently taking a small break and happen to come across this tutorial.
    I have an api that displays about 1460 objects in an array. There is no endpoint to comfortably implement pagination on the api. I have been thinking of a solution and wanted to use indexedDB to store the data and build my pagination around indexedDB.
    This tutorial just came at the right moment...

    • @LearnVue
      @LearnVue  ปีที่แล้ว +2

      the algorithm is getting too good 👀

  • @patrickraedler3656
    @patrickraedler3656 ปีที่แล้ว +1

    Just today I was looking for a library to implement infinite scrolling with Vue and didn't find anything that convinced me. This video comes just in time

    • @LearnVue
      @LearnVue  ปีที่แล้ว

      you're the second person to say this! glad my timing was good on this video haha

  • @MuhammadM1998
    @MuhammadM1998 ปีที่แล้ว +2

    Your videos are awesome. Your approach is similar to fireship (which is amazzzzing) but with extra focus on vue (which is more amazzzzzing to me). Thank You!

    • @LearnVue
      @LearnVue  ปีที่แล้ว

      Love this comment

  • @happynewyearw
    @happynewyearw ปีที่แล้ว +3

    Thanks for the awesome video! wonder what's the best way to support dynamic item height? just set the item height in useVirtualList comp. the min height of the range of item heights? any suggestion? thanks!

  • @SerpentsHiss
    @SerpentsHiss ปีที่แล้ว

    Thanks for the explanation of what the function actually did, I was banging my head against the wall because I thought it worked differently, as soon as I saw your explanation the fix was apparent.

  • @JannisAdmek
    @JannisAdmek ปีที่แล้ว +1

    This is really cool! Can I use this with a regular table as well? I have a table with 65000 items and I only see 10 at a time.

  • @oussamaabderrahim9793
    @oussamaabderrahim9793 ปีที่แล้ว +1

    Your tutorials are GOLD ! thank you

  • @roshanikumbharkar6266
    @roshanikumbharkar6266 ปีที่แล้ว

    It really worked for me after I look and try some tutorials, yours is the one that worked. Owe you a lot.

  • @Regeneration1996
    @Regeneration1996 ปีที่แล้ว +1

    Nice 👌 question can be used for a grid list of cards or card displayed flex, flex direction row and flex-wrap wrap?

  • @reagandesigns6432
    @reagandesigns6432 ปีที่แล้ว

    This is very helpful since I am fetching a data from an API with 400+ data. Question, because I am confused on how this would work if the v-for list are in 4 columns?

  • @anparisu
    @anparisu ปีที่แล้ว

    Amazing content as always, not sure why your channel is not more popular than it is! Definitely one of the hidden gems for Vue devs.

    • @LearnVue
      @LearnVue  ปีที่แล้ว

      I appreciate it. Hopefully the community continues to support me and the channel so it can keep growing!

  • @aliyahjanifahlomondot7049
    @aliyahjanifahlomondot7049 ปีที่แล้ว

    i really apreciate your help with dowloanding this software

  • @abinnouranas5719
    @abinnouranas5719 ปีที่แล้ว

    There is a CSS property (content-visibility : auto) that makes browsers do similar work and do not break document search, safari and firefox are not implementing it yet.

    • @LearnVue
      @LearnVue  ปีที่แล้ว

      i'm interested to see benchmarks with vue's vdom using content-visibility. also hope it gets more browser support.

  • @user-vs7tp1fn2n
    @user-vs7tp1fn2n 11 หลายเดือนก่อน

    This kind of videos are amazing, super helpful, thank you so much !

  • @user-nw8we9ul5p
    @user-nw8we9ul5p ปีที่แล้ว

    Great video thabbk you
    Wonder whether there would be a way to wrap the virtual list in a grid.. should try it out

    • @LearnVue
      @LearnVue  ปีที่แล้ว

      im curious too! let me know how it goes

  • @yte50
    @yte50 ปีที่แล้ว

    Once again you don't disappoint, like the video before watching, and loved it

  • @Akosiyawin
    @Akosiyawin ปีที่แล้ว

    It's kinda hard to implement if you have a dynamic height element.

  • @StefanIvanov188
    @StefanIvanov188 ปีที่แล้ว +1

    Awesome tutorials! But what if we have dynamic height for list item?

  • @takacszoltan5689
    @takacszoltan5689 ปีที่แล้ว

    thanks for the help it help my every thing i need to install

  • @CGVWEB
    @CGVWEB ปีที่แล้ว +1

    That's amazing! Very useful video. I will surely be implementing that on my Vue apps. Just one question... How would you handle the itemHeight propery if list items could vary in size? Like in the Twitter example some items have 3 lines of text but others only 1, and maybe some have media files.
    I see that useVirtualList accepts a function for the itemHeight prop and gives me the index of the element. I just don't know how to calculate the height that text would take after wrapping into multiple lines. Do you know how to do that?

    • @LearnVue
      @LearnVue  ปีที่แล้ว +1

      hmmm - im not sure about the exact implementation, but i know vue-virtual-scroller had that functionality for vue 2...maybe their source code might give some answers? github.com/Akryum/vue-virtual-scroller/blob/next/packages/vue-virtual-scroller/src/components/DynamicScroller.vue
      would love to know if you find out a good way to do it

    • @CGVWEB
      @CGVWEB ปีที่แล้ว

      @@LearnVue I will take a look at it to see what I can find. Thank you very much!

  • @codestuff3685
    @codestuff3685 ปีที่แล้ว +1

    Great one as always

  • @sostheneintamba1446
    @sostheneintamba1446 ปีที่แล้ว

    Thank you so much this helped a lot!!!! You saved my life

  • @karwanjabar5548
    @karwanjabar5548 ปีที่แล้ว

    can anyone tell me why it is not working now and official document says use another package instead
    how can i use with inertia

  • @kirankothandan5529
    @kirankothandan5529 ปีที่แล้ว

    I have a question. For example, if the user has millions of data and we are virtualizing the list, which is fine. However, I am curious to know how we should deal with the data. When the scroll hits a particular threshold, we load a new batch of data from the API. Should we concatenate the incoming data to the existing list? This approach may cause performance problems. I'm assuming that if the user scrolls up again, we may need to call the API again to load more data. Please advise.

  • @paoloforti8707
    @paoloforti8707 ปีที่แล้ว

    Hi, and thanks for the tutorial. I implemented a virtual list but I have a use case that requires the list to be sortable. Is that possible? I tried to sort the list passed as argument to the useVirtualList composable but the list is not being updated, while using filters works fine and the list gets updated.
    Am I missing something?

  • @bm2085
    @bm2085 ปีที่แล้ว

    Thank you, this was really helpful!

  • @benyaminbolhassani3708
    @benyaminbolhassani3708 ปีที่แล้ว

    one of the best explanations

  • @jonnysongs
    @jonnysongs ปีที่แล้ว

    Your vids are so good bro, thank you

  • @AndrewRusinas
    @AndrewRusinas ปีที่แล้ว +1

    What if item height is dynamic?

    • @LearnVue
      @LearnVue  ปีที่แล้ว +1

      hey added a pinned comment talking about this! sorry i missed it in the video though :/

  • @jalub014
    @jalub014 ปีที่แล้ว

    Is there a way to implement this for a page mode? Meaning scrolling of the page would use the virtual list without any nested scrollbars?

    • @LearnVue
      @LearnVue  ปีที่แล้ว +1

      my demo sets the width to the full screen width. does it still show multiple scrolls for you?
      scroll bar displays are hard to manage cross-browser and user settings wise - but hiding the scroll bar via css could be an option.

    • @jalub014
      @jalub014 ปีที่แล้ว

      @@LearnVue I will have to give it a try. I also need some content to be above and bellow the list for my case - the list is just a part of the page.

  • @carshoesch
    @carshoesch ปีที่แล้ว

    Does this work for vue2 as well?

  • @DanielTames
    @DanielTames ปีที่แล้ว

    Amazing video!
    thank you very much ❤❤

    • @LearnVue
      @LearnVue  ปีที่แล้ว

      Thanks for watching ❤️❤️

  • @edwinolvera2731
    @edwinolvera2731 ปีที่แล้ว

    Worked, thx

  • @alisson715
    @alisson715 ปีที่แล้ว

    Works well!! DANKEEE

  • @drisslachaal4293
    @drisslachaal4293 ปีที่แล้ว

    thank you so much dude you're a god

  • @iamthe_OBSERVER
    @iamthe_OBSERVER ปีที่แล้ว

    What font did you use when you pulled up the “yarn add @vueuse/core”? 2:12

    • @LearnVue
      @LearnVue  ปีที่แล้ว

      DM mono 🔥

  • @bluemesastudios
    @bluemesastudios ปีที่แล้ว

    Hi - beautiful work! I created a new Vue project and copied the code you provided. I may have done something incorrectly because my code loads all the elements at once : ( I check the inspector, and it does indeed confirm that all the 50 divs exist. So I changed the data parameter to 100, and sure enough, I have 100 divs that are all built and loaded...
    It may be a configuration issue - I don't know.
    I'm using Firefox.
    Do you happen to have a github repo for this? I would be happy to study it.
    Thanks!

    • @bluemesastudios
      @bluemesastudios ปีที่แล้ว

      I believe this is correctly copied - but I could be mistaken:
      import { ref } from 'vue'
      import { useVirtualList, useInfiniteScroll } from '@vueuse/core'
      const data = ref(Array.from(Array(500).keys(), () => 'Lorem Ipsum'))
      const { list, containerProps, wrapperProps } = useVirtualList(data, {
      // Keep 'itemHeight' in sync with the item's row.
      itemHeight: 96
      })
      useInfiniteScroll(
      containerProps.ref,
      () => {
      // load more
      data.value.push(...Array.from(Array(10).keys(), () => 'More Lorem Ipsum'))
      },
      {
      distance: 10
      }
      )

      Item #{{ index }}
      {{ data }}

  • @ZeyadMohamed-uj5pn
    @ZeyadMohamed-uj5pn ปีที่แล้ว

    I have a question?
    it doesn't work & I'm understand nothing.

  • @fenandosabado7185
    @fenandosabado7185 ปีที่แล้ว

    yo bro, really thankya. Big respect

    • @LearnVue
      @LearnVue  ปีที่แล้ว

      Glad it helped

  • @yt-black7442
    @yt-black7442 ปีที่แล้ว

    Very helpful

  • @ptugul
    @ptugul ปีที่แล้ว

    Woah, great video mate!

  • @leonardmbugua4319
    @leonardmbugua4319 ปีที่แล้ว

    Amazing video! Very useful

    • @LearnVue
      @LearnVue  ปีที่แล้ว

      glad you like it :)

  • @tumelopetsane5500
    @tumelopetsane5500 ปีที่แล้ว

    thanks helpful vid

  • @pyplacca
    @pyplacca ปีที่แล้ว

    Does this work with horizontal lists?

    • @LearnVue
      @LearnVue  ปีที่แล้ว

      the useInfiniteScroll can work in any direction, but from what I can find - the useVirtualList composable only goes vertically. but the principles should work the same if you roll your own virtual list logic

    • @pyplacca
      @pyplacca ปีที่แล้ว

      @@LearnVue got it. Thanks

  • @dbssman
    @dbssman ปีที่แล้ว

    Nice content as always!

  • @A28480
    @A28480 ปีที่แล้ว

    Great video!

  • @alejandrosauqueperez931
    @alejandrosauqueperez931 ปีที่แล้ว

    Amazing!

  • @shadkamel362
    @shadkamel362 ปีที่แล้ว

    that is great

  • @manums__
    @manums__ ปีที่แล้ว

    mine too

  • @zlotnytskiy
    @zlotnytskiy ปีที่แล้ว

    reddit developers, add this thing, please 🙏... I know that it is not on vue, but do something similar

  • @hongquannguyen8873
    @hongquannguyen8873 ปีที่แล้ว

    For once, the software is actually really useful

  • @barbieroalex
    @barbieroalex ปีที่แล้ว

    love it

  • @nandoandrade34
    @nandoandrade34 2 หลายเดือนก่อน

    amazingggggg

  • @eelitonmenezes8020
    @eelitonmenezes8020 ปีที่แล้ว

    +sub

  • @carlosestebanriosllanos8765
    @carlosestebanriosllanos8765 ปีที่แล้ว

    hahsdhahah good

  • @khushhirani9389
    @khushhirani9389 ปีที่แล้ว

    k; nbj

  • @alphacraftserver3691
    @alphacraftserver3691 ปีที่แล้ว

    Works well!! DANKEEE

  • @luisachaparro8446
    @luisachaparro8446 ปีที่แล้ว

    thank you so much dude you're a god

  • @maxavylys3169
    @maxavylys3169 ปีที่แล้ว

    Works well!! DANKEEE