vue-motion-counter 0.0.1
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/LICENSE +21 -0
- package/README.md +107 -0
- package/dist/App.vue.d.ts +2 -0
- package/dist/MotionCounter.vue.d.ts +60 -0
- package/dist/index.d.ts +2 -0
- package/dist/main.d.ts +1 -0
- package/dist/motion-counter.mjs +2199 -0
- package/dist/motion-counter.umd.js +15 -0
- package/dist/style.css +1 -0
- package/dist/test/MotionCounter.test.d.ts +1 -0
- package/dist/test/setup.d.ts +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mikan Harada
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Motion Counter
|
|
2
|
+
|
|
3
|
+
A Vue 3 counter component with smooth animations, inspired by motion design aesthetics.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Combination lock-style digit rolling animation
|
|
8
|
+
- Calculates shortest path (direct or wrap-around) for each digit
|
|
9
|
+
- Smooth step-by-step transitions using GSAP
|
|
10
|
+
- Configurable debounce for rapid updates
|
|
11
|
+
- Customizable size, color, and animation speed
|
|
12
|
+
- TypeScript support
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install vue-motion-counter
|
|
18
|
+
# or
|
|
19
|
+
pnpm add vue-motion-counter
|
|
20
|
+
# or
|
|
21
|
+
yarn add vue-motion-counter
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Global Registration
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { createApp } from 'vue';
|
|
30
|
+
import { MotionCounter } from 'vue-motion-counter';
|
|
31
|
+
import 'motion-counter/style.css';
|
|
32
|
+
|
|
33
|
+
const app = createApp(App);
|
|
34
|
+
app.component('MotionCounter', MotionCounter);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Local Registration
|
|
38
|
+
|
|
39
|
+
```vue
|
|
40
|
+
<script setup>
|
|
41
|
+
import { ref } from 'vue';
|
|
42
|
+
import { MotionCounter } from 'vue-motion-counter';
|
|
43
|
+
import 'motion-counter/style.css';
|
|
44
|
+
|
|
45
|
+
const count = ref(0);
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<MotionCounter v-model="count" />
|
|
50
|
+
</template>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Props
|
|
54
|
+
|
|
55
|
+
| Prop | Type | Default | Description |
|
|
56
|
+
| --------------------- | ---------------- | ----------- | ----------------------------------------------------- |
|
|
57
|
+
| `modelValue` | `number` | Required | The counter value to display |
|
|
58
|
+
| `debounce` | `number` | `300` | Debounce time in milliseconds for value updates |
|
|
59
|
+
| `size` | `number` | `48` | Font size in pixels |
|
|
60
|
+
| `color` | `string` | `'inherit'` | Text color |
|
|
61
|
+
| `stepDuration` | `number` | `80` | Duration of each digit step animation in milliseconds |
|
|
62
|
+
| `increasingDirection` | `'up' \| 'down'` | `'up'` | Scroll direction when digit increases |
|
|
63
|
+
|
|
64
|
+
## Animation Behavior
|
|
65
|
+
|
|
66
|
+
The component simulates a combination lock (rotary dial) effect:
|
|
67
|
+
|
|
68
|
+
- **Shortest Path Calculation**: For each digit, calculates whether to go directly or wrap around through 0
|
|
69
|
+
- Example: 2 → 8 goes down (2→1→0→9→8, 4 steps) instead of up (6 steps)
|
|
70
|
+
- Example: 8 → 2 goes up (8→9→0→1→2, 4 steps) instead of down (6 steps)
|
|
71
|
+
- **Step-by-Step Rolling**: Each digit animates through intermediate values
|
|
72
|
+
- **Blur Effect**: Smooth blur transition for a polished look
|
|
73
|
+
- **Configurable Direction**:
|
|
74
|
+
- `increasingDirection="up"` (default): digits scroll up when increasing
|
|
75
|
+
- `increasingDirection="down"`: digits scroll down when increasing
|
|
76
|
+
|
|
77
|
+
## Development
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Install dependencies
|
|
81
|
+
pnpm install
|
|
82
|
+
|
|
83
|
+
# Start dev server
|
|
84
|
+
pnpm dev
|
|
85
|
+
|
|
86
|
+
# Build for production
|
|
87
|
+
pnpm build
|
|
88
|
+
|
|
89
|
+
# Run tests
|
|
90
|
+
pnpm test
|
|
91
|
+
|
|
92
|
+
# Run tests once
|
|
93
|
+
pnpm test:run
|
|
94
|
+
|
|
95
|
+
# Run tests with coverage
|
|
96
|
+
pnpm test:coverage
|
|
97
|
+
|
|
98
|
+
# Lint code
|
|
99
|
+
pnpm lint
|
|
100
|
+
|
|
101
|
+
# Format code
|
|
102
|
+
pnpm format
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
MIT
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
modelValue: {
|
|
3
|
+
type: NumberConstructor;
|
|
4
|
+
required: true;
|
|
5
|
+
};
|
|
6
|
+
debounce: {
|
|
7
|
+
type: NumberConstructor;
|
|
8
|
+
default: number;
|
|
9
|
+
};
|
|
10
|
+
size: {
|
|
11
|
+
type: NumberConstructor;
|
|
12
|
+
default: number;
|
|
13
|
+
};
|
|
14
|
+
color: {
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
default: string;
|
|
17
|
+
};
|
|
18
|
+
stepDuration: {
|
|
19
|
+
type: NumberConstructor;
|
|
20
|
+
default: number;
|
|
21
|
+
};
|
|
22
|
+
increasingDirection: {
|
|
23
|
+
type: () => "up" | "down";
|
|
24
|
+
default: string;
|
|
25
|
+
validator: (v: string) => boolean;
|
|
26
|
+
};
|
|
27
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
28
|
+
modelValue: {
|
|
29
|
+
type: NumberConstructor;
|
|
30
|
+
required: true;
|
|
31
|
+
};
|
|
32
|
+
debounce: {
|
|
33
|
+
type: NumberConstructor;
|
|
34
|
+
default: number;
|
|
35
|
+
};
|
|
36
|
+
size: {
|
|
37
|
+
type: NumberConstructor;
|
|
38
|
+
default: number;
|
|
39
|
+
};
|
|
40
|
+
color: {
|
|
41
|
+
type: StringConstructor;
|
|
42
|
+
default: string;
|
|
43
|
+
};
|
|
44
|
+
stepDuration: {
|
|
45
|
+
type: NumberConstructor;
|
|
46
|
+
default: number;
|
|
47
|
+
};
|
|
48
|
+
increasingDirection: {
|
|
49
|
+
type: () => "up" | "down";
|
|
50
|
+
default: string;
|
|
51
|
+
validator: (v: string) => boolean;
|
|
52
|
+
};
|
|
53
|
+
}>> & Readonly<{}>, {
|
|
54
|
+
debounce: number;
|
|
55
|
+
size: number;
|
|
56
|
+
color: string;
|
|
57
|
+
stepDuration: number;
|
|
58
|
+
increasingDirection: "up" | "down";
|
|
59
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
60
|
+
export default _default;
|
package/dist/index.d.ts
ADDED
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './style.css';
|