Skip to content

Commit 2e53e8c

Browse files
committed
feat: page transition
1 parent 8d6e5c8 commit 2e53e8c

File tree

1 file changed

+71
-1
lines changed

1 file changed

+71
-1
lines changed

guide/animations.md

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,74 @@ Learn mode: [Demo](https://sli.dev/demo/starter/7) | [@vueuse/motion](https://mo
200200
201201
## Pages Transitions
202202
203-
> 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.
203+
> Available since v0.39.0
204+
205+
Slidev supports page transitions out of the box. You can enable it by setting the `transition` frontmatter option:
206+
207+
```md
208+
---
209+
transition: slide-left
210+
---
211+
```
212+
213+
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.
214+
215+
### Builtin Transitions
216+
217+
- `fade` - Crossfade in/out
218+
- `fade-out` - Fade out and then fade in
219+
- `slide-left` - Slides to the left, slide to right when going back
220+
- `slide-right` - Slides to the right, slide to left when going back
221+
- `slide-top` - Slides to the top, slide to bottom when going back
222+
- `slide-bottom` - Slides to the bottom, slide to top when going back
223+
224+
### Custom Transitions
225+
226+
Slidev's page transitions are powered by [Vue Transition](https://vuejs.org/guide/built-ins/transition.html). You can provide your custom transitions by:
227+
228+
```md
229+
---
230+
transition: my-transition
231+
---
232+
```
233+
234+
and then in your custom stylesheets:
235+
236+
```css
237+
.my-transition-enter-active,
238+
.my-transition-leave-active {
239+
transition: opacity 0.5s ease;
240+
}
241+
242+
.my-transition-enter-from,
243+
.my-transition-leave-to {
244+
opacity: 0;
245+
}
246+
```
247+
248+
Learn more how it works in [Vue Transition](https://vuejs.org/guide/built-ins/transition.html).
249+
250+
### Forward & Backward Transitions
251+
252+
You can specify different transitions for forward and backward navigation using `|` as a separator in the transition name:
253+
254+
```md
255+
---
256+
transition: go-forward | go-backward
257+
---
258+
```
259+
260+
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.
261+
262+
### Advanced Usage
263+
264+
The `transition` field accepts an option that will passed to the [`<TransitionGroup>`](https://vuejs.org/api/built-in-components.html#transition) component. For example:
265+
266+
```md
267+
---
268+
transition:
269+
name: my-transition
270+
enterFromClass: custom-enter-from
271+
enterActiveClass: custom-enter-active
272+
---
273+
```

0 commit comments

Comments
 (0)