Skip to content

Commit

Permalink
feat: page transition
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 29, 2023
1 parent 8d6e5c8 commit 2e53e8c
Showing 1 changed file with 71 additions and 1 deletion.
72 changes: 71 additions & 1 deletion guide/animations.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,74 @@ Learn mode: [Demo](https://sli.dev/demo/starter/7) | [@vueuse/motion](https://mo
## Pages Transitions
> Built-in support for slides is NOT YET provided in the current version. We are planning to add support for them in the next major version. Before that, you can still use your custom styles and libraries to do that.
> Available since v0.39.0
Slidev supports page transitions out of the box. You can enable it by setting the `transition` frontmatter option:
```md
---
transition: slide-left
---
```
This will give you a nice sliding effects on slide switching. Setting it in the frontmatter will apply to all slides. You can also set different transition per slide.

### Builtin Transitions

- `fade` - Crossfade in/out
- `fade-out` - Fade out and then fade in
- `slide-left` - Slides to the left, slide to right when going back
- `slide-right` - Slides to the right, slide to left when going back
- `slide-top` - Slides to the top, slide to bottom when going back
- `slide-bottom` - Slides to the bottom, slide to top when going back

### Custom Transitions

Slidev's page transitions are powered by [Vue Transition](https://vuejs.org/guide/built-ins/transition.html). You can provide your custom transitions by:

```md
---
transition: my-transition
---
```

and then in your custom stylesheets:

```css
.my-transition-enter-active,
.my-transition-leave-active {
transition: opacity 0.5s ease;
}

.my-transition-enter-from,
.my-transition-leave-to {
opacity: 0;
}
```

Learn more how it works in [Vue Transition](https://vuejs.org/guide/built-ins/transition.html).

### Forward & Backward Transitions

You can specify different transitions for forward and backward navigation using `|` as a separator in the transition name:

```md
---
transition: go-forward | go-backward
---
```

With this, when you go from slide 1 to slide 2, the `go-forward` transition will be applied. When you go from slide 2 to slide 1, the `go-backward` transition will be applied.

### Advanced Usage

The `transition` field accepts an option that will passed to the [`<TransitionGroup>`](https://vuejs.org/api/built-in-components.html#transition) component. For example:

```md
---
transition:
name: my-transition
enterFromClass: custom-enter-from
enterActiveClass: custom-enter-active
---
```

0 comments on commit 2e53e8c

Please sign in to comment.