@slidev/client 0.25.3 → 0.25.4

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.
package/constants.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { InjectionKey, Ref } from 'vue'
1
+ import { ComputedRef, InjectionKey, Ref } from 'vue'
2
2
 
3
3
  export const injectionClicks: InjectionKey<Ref<number>> = Symbol('v-click-clicks')
4
4
  export const injectionClicksElements: InjectionKey<Ref<(Element | string)[]>> = Symbol('v-click-clicks-elements')
5
5
  export const injectionOrderMap: InjectionKey<Ref<Map<number, HTMLElement[]>>> = Symbol('v-click-clicks-order-map')
6
6
  export const injectionClicksDisabled: InjectionKey<Ref<boolean>> = Symbol('v-click-clicks-disabled')
7
+ export const injectionSlideScale: InjectionKey<ComputedRef<number>> = Symbol('slidev-slide-scale')
7
8
 
8
9
  export const CLASS_VCLICK_TARGET = 'slidev-vclick-target'
9
10
  export const CLASS_VCLICK_HIDDEN = 'slidev-vclick-hidden'
@@ -1,11 +1,14 @@
1
1
  <script setup lang="ts">
2
- import { onMounted, ref, onBeforeUnmount } from 'vue'
2
+ import { onMounted, ref, watch, inject, onBeforeUnmount } from 'vue'
3
3
  import { drauu, loadCanvas } from '../logic/drawings'
4
+ import { injectionSlideScale } from '../constants'
4
5
 
6
+ const scale = inject(injectionSlideScale)!
5
7
  const svg = ref<SVGSVGElement>()
6
8
 
7
9
  onMounted(() => {
8
10
  drauu.mount(svg.value!, svg.value!.parentElement!)
11
+ watch(scale, scale => drauu.options.coordinateScale = 1 / scale, { immediate: true })
9
12
  loadCanvas()
10
13
  })
11
14
 
@@ -2,6 +2,7 @@
2
2
  import { useElementSize } from '@vueuse/core'
3
3
  import { computed, provide, ref, watchEffect } from 'vue'
4
4
  import { slideAspect, slideWidth, slideHeight, configs } from '../env'
5
+ import { injectionSlideScale } from '../constants'
5
6
 
6
7
  const props = defineProps({
7
8
  width: {
@@ -50,6 +51,8 @@ const className = computed(() => ({
50
51
  'select-none': !configs.selectable,
51
52
  'slidev-code-line-numbers': configs.lineNumbers,
52
53
  }))
54
+
55
+ provide(injectionSlideScale, scale)
53
56
  </script>
54
57
 
55
58
  <template>
package/logic/drawings.ts CHANGED
@@ -49,6 +49,7 @@ export const drawingMode = computed({
49
49
  export const drauuOptions: DrauuOptions = reactive({
50
50
  brush,
51
51
  acceptsInputTypes: computed(() => drawingEnabled.value ? undefined : ['pen' as const]),
52
+ coordinateTransform: false,
52
53
  })
53
54
  export const drauu = markRaw(createDrauu(drauuOptions))
54
55
 
package/logic/nav.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { computed, Ref, ref, nextTick } from 'vue'
2
- import { isString, SwipeDirection, timestamp, useSwipe } from '@vueuse/core'
2
+ import { isString, SwipeDirection, timestamp, usePointerSwipe } from '@vueuse/core'
3
3
  import { rawRoutes, router } from '../routes'
4
4
  import { configs } from '../env'
5
5
  import { useRouteQuery } from './route'
6
+ import { isDrawing } from './drawings'
6
7
 
7
8
  export { rawRoutes, router }
8
9
 
@@ -91,15 +92,24 @@ export function go(page: number, clicks?: number) {
91
92
 
92
93
  export function useSwipeControls(root: Ref<HTMLElement | undefined>) {
93
94
  const swipeBegin = ref(0)
94
- const { direction, lengthX, lengthY } = useSwipe(root, {
95
- onSwipeStart() {
95
+ const { direction, distanceX, distanceY } = usePointerSwipe(root, {
96
+ onSwipeStart(e) {
97
+ if (e.pointerType !== 'touch')
98
+ return
99
+ if (isDrawing.value)
100
+ return
96
101
  swipeBegin.value = timestamp()
97
102
  },
98
- onSwipeEnd() {
103
+ onSwipeEnd(e) {
104
+ if (e.pointerType !== 'touch')
105
+ return
99
106
  if (!swipeBegin.value)
100
107
  return
101
- const x = Math.abs(lengthX.value)
102
- const y = Math.abs(lengthY.value)
108
+ if (isDrawing.value)
109
+ return
110
+
111
+ const x = Math.abs(distanceX.value)
112
+ const y = Math.abs(distanceY.value)
103
113
  if (x / window.innerWidth > 0.3 || x > 100) {
104
114
  if (direction.value === SwipeDirection.LEFT)
105
115
  next()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/client",
3
- "version": "0.25.3",
3
+ "version": "0.25.4",
4
4
  "description": "Presentation slides for developers",
5
5
  "homepage": "https://sli.dev",
6
6
  "bugs": "https://github.com/slidevjs/slidev/issues",
@@ -13,13 +13,13 @@
13
13
  "author": "antfu <anthonyfu117@hotmail.com>",
14
14
  "dependencies": {
15
15
  "@antfu/utils": "^0.3.0",
16
- "@slidev/parser": "0.25.3",
17
- "@slidev/types": "0.25.3",
16
+ "@slidev/parser": "0.25.4",
17
+ "@slidev/types": "0.25.4",
18
18
  "@vueuse/core": "^6.4.0",
19
19
  "@vueuse/head": "^0.6.0",
20
20
  "@vueuse/motion": "^1.6.0",
21
21
  "codemirror": "^5.62.3",
22
- "drauu": "^0.1.2",
22
+ "drauu": "^0.2.0",
23
23
  "file-saver": "^2.0.5",
24
24
  "js-base64": "^3.7.1",
25
25
  "js-yaml": "^4.1.0",