@maas/vue-equipment 0.21.3 → 0.21.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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment/nuxt",
3
3
  "configKey": "vueEquipment",
4
- "version": "0.21.2"
4
+ "version": "0.21.3"
5
5
  }
@@ -7,32 +7,40 @@
7
7
  <script setup lang="ts">
8
8
  import { ref, inject, computed, onMounted, watch } from 'vue'
9
9
  import { unrefElement } from '@vueuse/core'
10
- import { animate, type Easing } from 'motion'
10
+ import {
11
+ animate,
12
+ type MotionKeyframesDefinition,
13
+ type AnimationControls,
14
+ type Easing,
15
+ } from 'motion'
11
16
  import { ScrollProgressKey } from '../symbols'
12
17
 
13
18
  interface Props {
14
- keyframes: Record<string, any> | null | undefined
19
+ keyframes: MotionKeyframesDefinition
15
20
  offset?: number[] | undefined
16
21
  easing?: Easing
22
+ progress?: number
17
23
  }
18
24
 
19
25
  const props = withDefaults(defineProps<Props>(), {
20
- keyframes: undefined,
21
- offset: undefined,
22
26
  easing: 'linear',
23
27
  })
24
28
 
25
- const animation = ref()
26
- const elRef = ref()
29
+ const animation = ref<AnimationControls | undefined>(undefined)
30
+ const elRef = ref<HTMLElement | undefined>(undefined)
27
31
 
28
32
  const progress = inject(
29
33
  ScrollProgressKey,
30
34
  computed(() => 0)
31
35
  )
32
36
 
37
+ const mappedProgress = computed(() => {
38
+ return props.progress || progress.value
39
+ })
40
+
33
41
  function createAnimation(currentTime: number = 0) {
34
42
  if (!props.keyframes) return
35
- animation.value = animate(unrefElement(elRef), props.keyframes, {
43
+ animation.value = animate(unrefElement(elRef)!, props.keyframes, {
36
44
  duration: 1,
37
45
  easing: props.easing || 'linear',
38
46
  offset: props.offset,
@@ -45,16 +53,16 @@ onMounted(() => {
45
53
  createAnimation()
46
54
  })
47
55
 
48
- watch(progress, (value) => {
49
- if (!value || !animation.value || !props.keyframes) return
56
+ watch(mappedProgress, (value) => {
57
+ if ((!value && value !== 0) || !animation.value || !props.keyframes) return
50
58
  animation.value.currentTime = value
51
59
  })
52
60
 
53
61
  watch(
54
62
  () => props.keyframes,
55
63
  () => {
56
- if (progress.value) {
57
- createAnimation(progress.value)
64
+ if (mappedProgress.value) {
65
+ createAnimation(mappedProgress.value)
58
66
  } else {
59
67
  createAnimation()
60
68
  }
@@ -1,20 +1,15 @@
1
- import { type Easing } from 'motion';
1
+ import { type MotionKeyframesDefinition, type Easing } from 'motion';
2
2
  interface Props {
3
- keyframes: Record<string, any> | null | undefined;
3
+ keyframes: MotionKeyframesDefinition;
4
4
  offset?: number[] | undefined;
5
5
  easing?: Easing;
6
+ progress?: number;
6
7
  }
7
8
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
8
- keyframes: undefined;
9
- offset: undefined;
10
9
  easing: string;
11
10
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
12
- keyframes: undefined;
13
- offset: undefined;
14
11
  easing: string;
15
12
  }>>>, {
16
- keyframes: Record<string, any> | null | undefined;
17
- offset: number[];
18
13
  easing: Easing;
19
14
  }, {}>, {
20
15
  default?(_: {}): any;
@@ -1,13 +1,12 @@
1
1
  <template>
2
2
  <div ref="elRef" class="magic-scroll-scene">
3
- <slot :map-value="mapValue" :progress="progress" />
3
+ <slot :progress="progress" />
4
4
  </div>
5
5
  </template>
6
6
 
7
7
  <script setup lang="ts">
8
8
  import { ref, provide, inject, onMounted, watch, nextTick, readonly } from 'vue'
9
- import { unrefElement, useIntersectionObserver } from '@vueuse/core'
10
- import { mapValue } from '@maas/vue-equipment/utils'
9
+ import { useIntersectionObserver } from '@vueuse/core'
11
10
  import { useScrollApi } from '../composables/useScrollApi'
12
11
  import {
13
12
  ScrollPositionKey,
@@ -71,6 +70,5 @@ useIntersectionObserver(
71
70
  { rootMargin: '150% 0px 150% 0px', threshold: 0.01 }
72
71
  )
73
72
 
74
- provide('mapValue', mapValue)
75
73
  provide(ScrollProgressKey, readonly(progress))
76
74
  </script>
@@ -1,4 +1,3 @@
1
- import { mapValue } from '@maas/vue-equipment/utils';
2
1
  import type { FromTo } from '../types';
3
2
  interface Props {
4
3
  from?: FromTo;
@@ -16,7 +15,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
16
15
  from: FromTo;
17
16
  }, {}>, {
18
17
  default?(_: {
19
- mapValue: typeof mapValue;
20
18
  progress: number;
21
19
  }): any;
22
20
  }>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment",
3
3
  "description": "A magic collection of Vue composables, plugins, components and directives",
4
- "version": "0.21.3",
4
+ "version": "0.21.4",
5
5
  "author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
6
6
  "devDependencies": {
7
7
  "@antfu/ni": "^0.21.12",