Skip to content

Commit

Permalink
feat: add slide page selector for custom styling
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 6, 2021
1 parent d5b6649 commit 77162cc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
17 changes: 16 additions & 1 deletion docs/guide/animations.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ By default, a subtle opacity transition is applied to those classes:

You can override them to customize the transition effects in your custom stylesheets.

For example, you can achieve the scale up transitions by:
For example, you can achieve the scaling up transitions by:

```css
// styles.css
Expand All @@ -136,6 +136,21 @@ For example, you can achieve the scale up transitions by:
}
```

To specify animations for only certain slide or layout

```scss
.slidev-page-7,
.slidev-layout.my-custom-layout {
.slidev-vclick-target {
transition: all 500ms ease;
}

.slidev-vclick-hidden {
transform: scale(0);
}
}
```

Learn more about [customizing styles](/custom/directory-structure#style).

## Pages Transitions
Expand Down
12 changes: 11 additions & 1 deletion packages/client/internals/SlideContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const props = defineProps({
scale: {
type: Number,
},
no: {
type: Number,
},
is: {
type: Object,
},
Expand Down Expand Up @@ -73,13 +76,20 @@ const style = computed(() => ({
width: `${slideWidth}px`,
transform: `translate(-50%, -50%) scale(${scale.value})`,
}))
const classes = computed(() => {
const no = props.no ?? props.route?.meta?.slide?.no
if (no != null)
return `slidev-page-${no}`
return ''
})
</script>

<template>
<div id="slide-container" ref="root">
<div id="slide-content" :style="style">
<slot>
<component :is="props.is || route.component" />
<component :is="props.is || route.component" :classes="classes" />
</slot>
</div>
<slot name="controls" />
Expand Down
1 change: 1 addition & 0 deletions packages/client/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ declare module 'vue-router' {
start: number
end: number
id: number
no: number
file: string
}
}
Expand Down

0 comments on commit 77162cc

Please sign in to comment.