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

How to use with dynamic growing/shrinking lists / default values. #14

Closed
rharink opened this issue Jul 1, 2018 · 2 comments
Closed

Comments

@rharink
Copy link

rharink commented Jul 1, 2018

Hi, first of all, I love the library! but i'm struggling to create a dynamic carrousel that appends / removes items in a list. I get errors for the items that do not exist yet in the new list. Is there a way to provide default values for new items?

Simple example:

<template>
<ul>
  <Motion :values="children">
    <div slot-scope="_children">
      <div v-for="(child, index) in _children" :key="index">
        <p>{{child.offset}}</p>
      </div>
    </div>
  </Motion>
  <button v-on:click="testPush">test Push</button>
  <button v-on:click="test">test</button>
</ul>
</template>

<script lang="ts">
import { Motion } from "vue-motion"

export default {
  components: {
    Motion
  },
  data() {
    return {
      children: [{
        offset: 0,
      }],
    }
  },
  methods: {
    test() {
      this.$data.children = [{offset: 100}, {offset: 200}]
    },
    testPush() {
      this.$data.children.push({offset: 200})
    }
  }
}
</script>

Thanks!

posva added a commit that referenced this issue Jul 1, 2018
@posva
Copy link
Owner

posva commented Jul 1, 2018

I released a version that fixed the problem of setting to a bigger array but I still need to manage adding elements and shrinking + growing arrays (right now, old values are not cleaned up)

@rharink
Copy link
Author

rharink commented Jul 3, 2018

Ok, thanks for the effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants