0.0.7 • Published 1 year ago

@ggc12319/vue3-scroll-number v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

vue3-scroll-number

A vue3 digital scroll up and down animation component

install

pnpm add @ggc12319/vue3-scroll-number

configuration

import { createApp } from 'vue'
import App from './App.vue'
import ScrollNumber from '@ggc12319/vue3-scroll-number'
import '@ggc12319/vue3-scroll-number/style.css'

createApp(App)
  .use(ScrollNumber, {
    transformDuration: 1500,
    fractionDigits: 3,
    prefix: '^_^',
    infix: '$',
    suffix: '@_@',
    thousandSeparator: ','
  })
  .mount('#app')

Used in components

<script setup lang="ts">
import { ref } from 'vue'
const value = ref(-123.45)
const add = () => {
  value.value += 20
}
const sub = () => {
  value.value -= 20
}

const percentage = ref(24.8)
const addPercentage = () => {
  percentage.value += 2.4
}
const subPercentage = () => {
  percentage.value -= 2.4
}
</script>

<template>
  <div>
    <ScrollNumber :value="value" />
    <span style="margin-left: 50px">
      <button @click="add">add</button>
      <button @click="sub">sub</button>
    </span>
  </div>
  <div>
    <ScrollNumber :value="percentage" :fractionDigits="1" prefix="" infix="" suffix="%" />
    <span style="margin-left: 50px">
      <button @click="addPercentage">add</button>
      <button @click="subPercentage">sub</button>
    </span>
  </div>
</template>

props

AttributeDescriptionTypeDefault
valuefigurenumber-
transformDurationtransform durationnumber1500
fractionDigitsfraction digitsnumber0
prefixprefixstring''
infixprefix but after the negative signstring''
suffixsuffixstring''
thousandSeparatorthe thousand separatorstring,
0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago