motiondivision / motionone

https://motion.dev
MIT License
2.86k stars 52 forks source link

[Bug] v-show property set to false causing the first animation lost on clicking to show action #194

Closed tobatha closed 9 months ago

tobatha commented 1 year ago

1. Describe the bug Tried the official example here, if the show: false, clicking toggle button will lose the animation for the first time the box displayed, and later on the animation worked as expected, i'm not sure if i setup something wrong hopefully someone could help me out here, thanks.

2. IMPORTANT: Provide a CodeSandbox reproduction of the bug

<template>
  <div class="container">
    <Presence>
      <Motion
        v-show="show"
        :initial="{ opacity: 0, scale: 0 }"
        :animate="{ opacity: 1, scale: 1 }"
        :exit="{ opacity: 0, scale: 0.6 }"
        class="box"
      />
    </Presence>
    <button @click="show = !show">
      Toggle
    </button>
  </div>
</template>

<script>
import { Motion, Presence } from "motion/vue"

export default {
  components: { Motion, Presence },
  data() {
    return { show: false }
  }
}
</script>

<style>
.container {
  width: 100px;
  height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.container button {
  cursor: pointer;
}
.box {
  width: 100px;
  height: 100px;
  border-radius: 10px;
  background-color: var(--splash);
}
</style>

3. Steps to reproduce

Steps to reproduce the behavior:

  1. Load the example component on the page
  2. show: false is set, and the box is visible, and then click on 'Toggle'
  3. The div box is displayed but without animation
  4. Keep clicking on Toggle, the animation worked fine later on

4. Expected behavior

When div box is not visible, clicking Toggle button with display the box with preset animation

5. Video or screenshots https://github.com/motiondivision/motionone/assets/2382153/d2297cfc-6d47-4493-95c9-8d781103607d

6. Browser details

  "dependencies": {
    "axios": "^1.4.0",
    "dayjs": "^1.11.7",
    "motion": "^10.16.2",
    "pinia": "^2.1.3",
    "vue": "^3.2.47",
    "vue-router": "^4.2.2"
  },
tobatha commented 1 year ago

For all those who got this weird issue, FYI #53

mattgperry commented 9 months ago

This is now a wontfix, see https://github.com/motiondivision/motionone/discussions/241

Hopefully future maintainers will have more time to take a look at this one!