cbvirtua 1.0.47 → 1.0.48

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.
Files changed (2) hide show
  1. package/Signature.vue +127 -0
  2. package/package.json +1 -1
package/Signature.vue CHANGED
@@ -364,3 +364,130 @@ onMounted(() => {
364
364
  }
365
365
  }
366
366
  </style>
367
+ <template>
368
+ <div class="progress-bar">
369
+ <div class="bg"></div>
370
+ <div class="bar" :style="{ width: progress + '%' }"></div>
371
+ <div class="label">{{ progress }}%</div>
372
+ </div>
373
+ </template>
374
+
375
+ <script>
376
+ export default {
377
+ data() {
378
+ return {
379
+ progress: 0,
380
+ isPlaying: false,
381
+ isCompleted: false
382
+ }
383
+ },
384
+ mounted() {
385
+ this.start();
386
+ },
387
+ methods: {
388
+ start() {
389
+ this.isPlaying = true;
390
+ this.animateProgress(90)
391
+ .then(() => {
392
+ if (!this.isCompleted) {
393
+ this.animateProgress(100);
394
+ }
395
+ })
396
+ .catch((error) => {
397
+ console.error('Progress error', error);
398
+ });
399
+ },
400
+ animateProgress(target) {
401
+ return new Promise((resolve, reject) => {
402
+ let start = this.progress;
403
+ const end = target;
404
+ const duration = (target - start) * 150;
405
+
406
+ const doAnimation = () => {
407
+ const elapsed = Date.now() - startTime;
408
+ const progress = Math.min(elapsed / duration, 1);
409
+
410
+ this.progress = start + ((end - start) * progress);
411
+
412
+ if (progress === 1) {
413
+ resolve();
414
+ } else if (this.isCompleted) {
415
+ resolve();
416
+ } else {
417
+ requestAnimationFrame(doAnimation);
418
+ }
419
+ };
420
+
421
+ const startTime = Date.now();
422
+ requestAnimationFrame(doAnimation);
423
+ });
424
+ },
425
+ finish() {
426
+ this.isCompleted = true;
427
+ this.progress = 100;
428
+ }
429
+ }
430
+ };
431
+ </script>
432
+
433
+ <div class="progress" :style="{width, height}">
434
+ <svg viewBox="0 0 96 96" class="svg-circle-progress" style="width: 96px; height: 96px;">
435
+ <circle r="40" cx="48" cy="48" fill="none" stroke-miterlimit="20" stroke-width="10" class="svg-progress"
436
+ style="stroke-dasharray: 275, 279.602;stroke:#eee;">
437
+ </circle>
438
+ <circle r="40" cx="48" cy="48" fill="none" stroke-miterlimit="20" stroke-width="10"
439
+ class="svg-progress"
440
+ :style="`stroke-dasharray: ${progressValue}, 279.602;stroke:${color};`">
441
+ </circle>
442
+ </svg>
443
+ <div class="mask">
444
+ {{ progress}}%
445
+ </div>
446
+ </div>
447
+ <script setup>
448
+ import { ref, toRefs, watch } from 'vue'
449
+
450
+ const props = defineProps({
451
+ progress: {
452
+ type: Number,
453
+ default: () => 20
454
+ },
455
+ color: {
456
+ type: String,
457
+ default: () => "#FFAFAF"
458
+ },
459
+ width: {
460
+ type: String,
461
+ default: () => "210px"
462
+ },
463
+ height: {
464
+ type: String,
465
+ default: () => "100px"
466
+ },
467
+ })
468
+ const { height, width, color, progress } = toRefs(props)
469
+ const progressValue = ref((progress.value / 100) * 250)
470
+
471
+ watch(progress, (newValue) => {
472
+ progressValue.value = (newValue / 100) * 250
473
+ })
474
+
475
+ </script>
476
+ <style lang="css" scoped>
477
+ .progress {
478
+ display: inline-block;
479
+ position: relative;
480
+ height: 100px;
481
+ text-align: center;
482
+ }
483
+ .svg-circle-progress {
484
+ position: relative;
485
+ transform: rotate(-90deg);
486
+ }
487
+ .svg-progress {
488
+ stroke: #2196f3;
489
+ stroke-linecap: round;
490
+ transition: all .3s linear;
491
+ }
492
+ </style>
493
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cbvirtua",
3
- "version": "1.0.47",
3
+ "version": "1.0.48",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {