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: v-motion #1481

Merged
merged 9 commits into from Apr 5, 2024
Merged

fix: v-motion #1481

merged 9 commits into from Apr 5, 2024

Conversation

KermanX
Copy link
Member

@KermanX KermanX commented Mar 30, 2024

This PR includes:

  • No longer need preload: false when using v-motion
  • Allow to have variants based on current click (currently absolute click only)
  • Allow to use v-click and v-motion together. The motion will only start after the element is shown by v-click.
  • Fix watchers leak in Slidev directives

Example

<div
  v-motion
  :initial="{ x: 100, y: 0 }"
  :enter="{ x: 400, y: 0, rotate: 0 }"
  :click-1="{ x: 400, y: 100 }"
  :click-2="{ x: 400, y: 200 }"
  :click-1-2="{ rotate: 90 }"
  :leave="{ x: 800, y: 400 }"
  w-30 b b-white>
  clicks {{ $clicks }}
</div>

<div v-click v-motion
  :initial="{ x: -100 }"
  :enter="{ x: 0 }"
  :leave="{ x: 100 }"
>
  ABCD
</div>

The meanings of variants:

  • initial: currentPage < thisPage, or v-click hides the current element because $clicks is too small.
  • enter: When currentPage === thisPage, and v-click shows the element. Priority: lowest
  • click-x: x is a number representing the absolute click num. The variant will take effect if $clicks>=x. Priority: x
  • click-x-y: The variant will take effect if x<=$clicks<y. Priority: x
  • leave: currentPage > thisPage, or v-click hides the current element because $clicks is too large.

The variants will be combined according to priority.

Preview

QQ录屏20240401180122

Todos

Copy link

netlify bot commented Mar 30, 2024

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 022f4bd
🔍 Latest deploy log https://app.netlify.com/sites/slidev/deploys/660e2000c309aa0008efa378
😎 Deploy Preview https://deploy-preview-1481--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

demo/starter/slides.md Outdated Show resolved Hide resolved
@KermanX
Copy link
Member Author

KermanX commented Mar 30, 2024

I've just found some designs that may be better. (Too busy these days😭)

@KermanX KermanX marked this pull request as draft March 30, 2024 11:54
@KermanX KermanX marked this pull request as ready for review April 4, 2024 03:35
@antfu antfu merged commit 179a313 into slidevjs:main Apr 5, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants