@slidev/client 52.7.0 → 52.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,10 @@ const props = defineProps({
34
34
  type: String,
35
35
  default: '',
36
36
  },
37
+ duration: {
38
+ type: Number,
39
+ default: configs.magicMoveDuration,
40
+ },
37
41
  })
38
42
 
39
43
  const steps = JSON.parse(lz.decompressFromBase64(props.stepsLz)) as KeyedTokensInfo[]
@@ -42,6 +46,8 @@ const { isPrintMode } = useNav()
42
46
  const id = makeId()
43
47
 
44
48
  const stepIndex = ref(0)
49
+ // Used to skip the animation on the first tick.
50
+ const isFirstTick = ref(true)
45
51
  const container = ref<HTMLElement>()
46
52
 
47
53
  const showCopyButton = computed(() => {
@@ -89,6 +95,7 @@ onMounted(() => {
89
95
  const clickInfo = clicks.calculateSince(props.at, clickCounts - 1)
90
96
  clicks.register(id, clickInfo)
91
97
 
98
+ let cancelTick: () => void = () => { }
92
99
  watch(
93
100
  () => clicks.current,
94
101
  () => {
@@ -107,9 +114,24 @@ onMounted(() => {
107
114
  currentClickSum += current.length || 1
108
115
  }
109
116
 
117
+ // It seems ticks may not be executed in order. Cancel previous ones, because
118
+ // clicks.current is first 0 then immediately updated when refreshing the slide.
119
+ cancelTick()
120
+ let isCanceled = false
121
+ cancelTick = () => {
122
+ isCanceled = true
123
+ }
124
+
110
125
  nextTick(async () => {
126
+ if (isCanceled) {
127
+ return
128
+ }
111
129
  stepIndex.value = step
112
-
130
+ if (isFirstTick.value) {
131
+ nextTick(() => {
132
+ isFirstTick.value = false
133
+ })
134
+ }
113
135
  await sleep(0)
114
136
 
115
137
  const pre = container.value?.querySelector('.shiki') as HTMLElement
@@ -158,8 +180,10 @@ onMounted(() => {
158
180
  :animate="!isPrintMode"
159
181
  :options="{
160
182
  globalScale: scale * zoom,
161
- // TODO: make this configurable later
162
- duration: 800,
183
+ // Use duration 0 to skip animation instead of using the animate prop,
184
+ // because moving from non-animated to animated causes issues with
185
+ // new elements. Unfortunately, this causes a flash.
186
+ duration: isFirstTick ? 0 : $props.duration,
163
187
  stagger: 1,
164
188
  }"
165
189
  />
package/constants.ts CHANGED
@@ -86,4 +86,5 @@ export const HEADMATTER_FIELDS = [
86
86
  'wakeLock',
87
87
  'seoMeta',
88
88
  'notesAutoRuby',
89
+ 'magicMoveDuration',
89
90
  ]
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
3
  "type": "module",
4
- "version": "52.7.0",
4
+ "version": "52.8.0",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  "@slidev/rough-notation": "^0.1.0",
39
39
  "@typescript/ata": "^0.9.8",
40
40
  "@unhead/vue": "^2.0.19",
41
- "@unocss/reset": "^66.5.4",
41
+ "@unocss/reset": "^66.5.5",
42
42
  "@vueuse/core": "^14.0.0",
43
43
  "@vueuse/math": "^14.0.0",
44
44
  "@vueuse/motion": "^3.0.3",
@@ -57,12 +57,12 @@
57
57
  "shiki": "^3.15.0",
58
58
  "shiki-magic-move": "^1.2.1",
59
59
  "typescript": "^5.9.3",
60
- "unocss": "^66.5.4",
61
- "vue": "^3.5.23",
60
+ "unocss": "^66.5.5",
61
+ "vue": "^3.5.24",
62
62
  "vue-router": "^4.6.3",
63
63
  "yaml": "^2.8.1",
64
- "@slidev/parser": "52.7.0",
65
- "@slidev/types": "52.7.0"
64
+ "@slidev/parser": "52.8.0",
65
+ "@slidev/types": "52.8.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "vite": "^7.2.2"