Skip to content

RollingText 翻滚文本动效

文本翻滚动效,可以翻滚数字和其他类型文本。请升级 ryxon 到 >= 1.12.0 版本来使用该组件。

基础用法

设置翻滚方向

设置各数位停止顺序

翻转非数字内容

API

Props

参数说明类型默认值
start-num起始数值number0
target-num目标数值number-
text-list内容数组,用于翻转非数字内容string[][]
duration动画时长,单位为秒number2
direction文本翻滚方向,值为 downupstringdown
auto-start是否自动开始动画booleantrue
stop-order各个数位动画停止先后顺序,值为 ltrrtlstringltr
height数字高度,单位为 pxnumber40

方法

通过 ref 可以获取到 RollingText 实例并调用实例方法,详见组件实例方法

方法名说明参数返回值
start开始动画--
reset重置动画--

类型定义

组件导出以下类型定义:

ts
import type {
  RollingTextProps,
  RollingTextInstance,
  RollingTextDirection,
  RollingTextStopOrder
} from 'ryxon'

RollingTextInstance 是组件实例的类型,用法如下:

ts
import { ref } from 'vue'
import type { RollingTextInstance } from 'ryxon'

const rollingTextRef = ref<RollingTextInstance>()

rollingTextRef.value?.start()

主题定制

样式变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 组件

名称默认值描述
--r-rolling-text-backgroundinherit单个数位背景色
--r-rolling-text-colorvar(--r-text-color)数字颜色
--r-rolling-text-font-sizevar(--r-font-size-md)字体大小
--r-rolling-text-gap0px数位之间的间隔
--r-rolling-text-item-width15px单个数位宽度
--r-rolling-text-item-border-radius0px单个数位边框圆角

Released under the MIT License.