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

fix(VVirtualScroll): invoke handleScroll when items change #16726

Closed
wants to merge 1 commit into from

Conversation

johnleider
Copy link
Member

Motivation and Context

fixes #16725

Markup:

<template>
  <VApp>
    <VMain>
      <VSheet class="mx-5">
        <VVirtualScroll :items="items" height="300" :visible-items="10">
          <template #default="{ item, index }">
            <p>
              {{ index + 1 }} - {{ item }}
            </p>
          </template>
        </VVirtualScroll>
        <p class="mt-3">Total: {{ items.length }}</p>
      </VSheet>
    </VMain>
  </VApp>
</template>

<script setup>
  import { onMounted, onUnmounted, ref } from 'vue'

  const items = ref([
    'sentence The rough teacher sadly dodged because some teacher humbly rolled below a rough hamster which, became a dumb, lovely old lady.',
    'The soft hamster elegantly kicked because some old lady proudly died above a vibrating boy which, became a lazy, beautiful clock.',
    'The soft plastic calmly died because some old lady proudly died above a lovely old lady which, became a vibrating, soft hamster.',
    'The professional professor proudly rolled because some boy precisely flew up a hot dog which, became a soft, rough bird.',
    'The vibrating old lady slowly rolled because some hamster calmly slept across a soft teacher which, became a beautiful, rough old lady.',
    'sentence The rough teacher sadly dodged because some teacher humbly rolled below a rough hamster which, became a dumb, lovely old lady.',
    'The soft hamster elegantly kicked because some old lady proudly died above a vibrating boy which, became a lazy, beautiful clock.',
    'The soft plastic calmly died because some old lady proudly died above a lovely old lady which, became a vibrating, soft hamster.',
    'The professional professor proudly rolled because some boy precisely flew up a hot dog which, became a soft, rough bird.',
    'The vibrating old lady slowly rolled because some hamster calmly slept across a soft teacher which, became a beautiful, rough old lady.',
  ])

  const nouns = ['bird', 'clock', 'boy', 'plastic', 'duck', 'teacher', 'old lady', 'professor', 'hamster', 'dog']
  const verbs = ['kicked', 'ran', 'flew', 'dodged', 'sliced', 'rolled', 'died', 'breathed', 'slept', 'killed']
  const adjectives = ['beautiful', 'lazy', 'professional', 'lovely', 'dumb', 'rough', 'soft', 'hot', 'vibrating', 'slimy']
  const adverbs = ['slowly', 'elegantly', 'precisely', 'quickly', 'sadly', 'humbly', 'proudly', 'shockingly', 'calmly', 'passionately']
  const preposition = ['down', 'into', 'up', 'on', 'upon', 'below', 'above', 'through', 'across', 'towards']

  function sentence () {
    const rand1 = Math.floor(Math.random() * 10)
    const rand2 = Math.floor(Math.random() * 10)
    const rand3 = Math.floor(Math.random() * 10)
    const rand4 = Math.floor(Math.random() * 10)
    const rand5 = Math.floor(Math.random() * 10)
    const rand6 = Math.floor(Math.random() * 10)
    return 'The ' + adjectives[rand1] + ' ' + nouns[rand2] + ' ' + adverbs[rand3] + ' ' + verbs[rand4] + ' because some ' + nouns[rand1] + ' ' + adverbs[rand1] + ' ' + verbs[rand1] + ' ' + preposition[rand1] + ' a ' + adjectives[rand2] + ' ' + nouns[rand5] + ' which, became a ' + adjectives[rand3] + ', ' + adjectives[rand4] + ' ' + nouns[rand6] + '.'
  }

  const interval = setInterval(() => {
    // console.log('adding more sentences')
    for (let i = 0; i < 5; i++) {
      items.value.push(sentence())
    }
  }, 2000)

  onUnmounted(() => {
    clearInterval(interval)
  })
</script>

@johnleider johnleider added T: bug Functionality that does not work as intended/expected P: elite sponsor C: VVirtualScroll labs labels Feb 20, 2023
@johnleider johnleider added this to the v3.1.x milestone Feb 20, 2023
@johnleider johnleider requested a review from KaelWD February 20, 2023 19:57
@johnleider johnleider self-assigned this Feb 20, 2023
@johnleider johnleider requested a review from nekosaur February 20, 2023 19:59
@johnleider johnleider marked this pull request as draft February 20, 2023 20:12
@vuetifyjs vuetifyjs deleted a comment from KaelWD Feb 21, 2023
@johnleider
Copy link
Member Author

closing in favor of #16736

@johnleider johnleider closed this Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VVirtualScroll labs P: elite sponsor T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report][3.1.4] VVirtualScroll is not adjusting scroll for newly added items
1 participant