Skip to content

Commit 998a6b7

Browse files
committed
chore(release): v1.2.0 - Core upgrade, Vue sync, UI overhaul
1 parent 71c537e commit 998a6b7

19 files changed

Lines changed: 2138 additions & 1239 deletions

File tree

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
# Changelog
22

3+
## [1.2.0] - 2026-01-06
4+
5+
### ✨ 新功能
6+
- **核心功能升级**
7+
- **Intl 支持**`value`传数字时,支持`numberFormat`属性,配合`Intl.NumberFormat`使用, 支持国际化格式化。
8+
- **`autoScale`** 自动大小缩放适配容器,注意需要父控件给定宽高。
9+
- **A11y & Reduced Motion**: Automatically respects system `prefers-reduced-motion` preferences (can be overridden via `disableAnimation`).
10+
- **`fadingEdge`** 上下边缘模糊效果。
11+
- **`disableAnimation`** 禁用动画。
12+
- **缓动函数增强**:增加了更多的内置缓动选项(如 easeOutBack),并优化了自定义 Easing 函数的类型支持。
13+
- **前后缀完善**: 完善了 prefix 和 suffix 属性,确保静态文本不参与列滚动逻辑,且在布局切换时保持稳定。
14+
- **无障碍优化 (A11y)**: ARIA + Screen Reader 支持。自动检测系统 `prefers-reduced-motion` 设置,尊重用户减弱动画的偏好(也可手动通过 `disableAnimation` 强制禁用)。
15+
- **Vue 组件同步**
16+
- **属性对齐**:为 Vue 版本同步增加了 prefix、suffix、autoScale、fadingEdge 和 numberFormat等 Props。
17+
- **回调事件**:增加了 @animation-end 事件分发。
18+
- **Intl 支持**:优化了 :number-format 属性的响应式逻辑,使其能配合国际化格式实时更新。
19+
20+
- **官网改造升级** — UI调整,Demo增加更多控制选项,支持 React/Vue 代码实时预览,100% 适配中英双语切换,集成 StackBlitz 一键导出在线运行。
21+
- **预设字符集 (Presets)替换TickerUtils** — 提供 `NUMBER`, `ALPHABET`, `CURRENCY`, `ALPHANUMERIC` 等常用字符集常量。
22+
23+
24+
### ⚡ 性能与优化
25+
- **同步初始化 (Zero Latency)** — Ticker 组件现在会在挂载瞬间同步计算首屏列状态,彻底解决刷新网页时的“白屏闪烁”问题。
26+
- **连贯滚动增强** — 优化了挂载瞬间的值变更逻辑,确保即使在极速数据更新下,动画也能从初始值平滑过渡。
27+
- **更新数据流** — 优化 Demo 数据更新循环,实现挂载即更新,无需额外等待初始间隔。
28+
29+
### 📝 文档
30+
- 重构 README “字符集配置详解”章节,推荐使用 `Presets` 常量。
31+
- 补全中英文 API Props 对齐。
32+
33+
---
34+
335
## [1.1.0] - 2026-01-04
436

537
### ✨ 新功能

CHANGELOG_EN.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
# Changelog
22

3+
## [1.2.0] - 2026-01-06
4+
5+
### ✨ New Features
6+
- **Core Functionality Upgrade**
7+
- **Intl Support**: Added `numberFormat` prop for `value` (number type), leveraging `Intl.NumberFormat` for internationalized formatting.
8+
- **`autoScale`**: Automatically scales content to fit container (requires parent container with defined dimensions).
9+
- **`fadingEdge`**: Added top/bottom fading edge effects.
10+
- **`disableAnimation`**: Option to disable animation entirely.
11+
- **Easing Enhancements**: Added more built-in easing options (e.g., `easeOutBack`) and optimized type support for custom easing functions.
12+
- **Prefix/Suffix Refinement**: Improved `prefix` and `suffix` props to ensure static text stays stable during layout changes and is excluded from column scrolling logic.
13+
- **A11y & Reduced Motion**: ARIA + Screen Reader support。Automatically respects system `prefers-reduced-motion` preferences (can be overridden via `disableAnimation`).
14+
- **Vue Component Sync**
15+
- **Prop Alignment**: Synced `prefix`, `suffix`, `autoScale`, `fadingEdge`, and `numberFormat` props to the Vue version.
16+
- **Events**: Added `@animation-end` event emission.
17+
- **Intl Support**: Optimized reactive logic for `:number-format` to support real-time updates for international formatting.
18+
- **Official Site Overhaul** — UI adjustments, more control options in Demo, real-time React/Vue code preview, 100% bilingual (EN/ZH) support, and one-click StackBlitz export.
19+
- **Character Presets** — Replaced `TickerUtils` with `Presets` constants (`NUMBER`, `ALPHABET`, `CURRENCY`, `ALPHANUMERIC`).
20+
21+
### ⚡ Performance & Optimization
22+
- **Zero-Latency Initialization** — Synchronously calculate ticker columns on mount to eliminate the "blank flash" on page refresh.
23+
- **Animation Continuity** — Refined value update logic during mounting to ensure smooth transitions from the very first data change.
24+
- **Data Loop Optimization** — Demo updates now trigger immediately upon mounting without waiting for the first interval.
25+
26+
### 📝 Documentation
27+
- Reorganized README's "Character Configuration" section to recommend `Presets` usage.
28+
- Simplified API Props tables and synchronized EN/ZH versions.
29+
30+
---
31+
332
## [1.1.0] - 2026-01-04
433

534
### ✨ New Features

README.md

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
| | |
3333
| :--- | :--- |
3434
| **🌏 多字符集支持**<br>支持中英、数字、Emoji等混合滚动,基于 Unicode 宽度自动调整间距 | **🧠 智能差异动画**<br>Levenshtein 算法计算最小变更路径,相同的字符保持静止 |
35-
| **⚡ 平滑中断**<br>动画过程中值突变时,从当前动态位置无缝流向新目标 | **📈 丰富动效**<br>内置 `linear`, `bounce`, `easeInOut` 等缓动,支持 `charWidth` 微调 |
36-
| **🦄 双框架支持**<br>提供 React (Hooks) 和 Vue 3 (Composition) 组件,API 统一 | **🚀 极致性能**<br>基于 `RAF` 驱动,无多余 DOM 操作,适合高频数据流场景 |
35+
| **⚡ 平滑中断**<br>动画过程中值突变时,从当前动态位置无缝流向新目标 | **📈 丰富动效**<br>内置多种缓动函数,支持自定义,支持 `charWidth` 微调 |
36+
| **🦄 双框架支持**<br>提供 React (Hooks) 和 Vue 3 (Composition) 组件,API 统一 | **🚀 极致性能**<br>基于 `RAF` 驱动,支持 **自动缩放****边缘模糊****动画禁用** |
3737

3838
## 📦 安装
3939

@@ -141,51 +141,59 @@ const price = ref('73.18');
141141

142142
| 属性 | 类型 | 默认值 | 说明 |
143143
|------|------|--------|------|
144-
| `value` | `string` | - | 要显示的文本值(必填) |
144+
| `value` | `string`\|`number` | - | 要显示的文本值(必填) |
145145
| `duration` | `number` | `500` | 动画持续时间(毫秒) |
146146
| `easing` | `EasingName \| function` | `'easeInOut'` | 缓动函数:`linear``easeIn``easeOut``easeInOut``bounce`,或自定义 `(t: number) => number` |
147147
| `direction` | `string` | `'ANY'` | 滚动方向:`UP``DOWN``ANY`(自动选择最短路径) |
148148
| `charWidth` | `number` | `1` | 字符宽度倍率(基准为 0.8em) |
149149
| `characterLists` | `string[]` | `['0123456789']` | 支持的字符列表 |
150150
| `className` | `string` | `''` | 自定义 CSS 类名 |
151151
| `animateOnMount` | `boolean` | `false` | 首次加载时是否播放动画 |
152-
| `disabled` | `boolean` | `false` | 禁用动画,直接显示最终值 |
152+
| `disableAnimation` | `boolean` | `false` | 禁用动画,直接显示最终值 |
153+
| `autoScale` | `boolean` | `false` | 是否开启自动缩放以适配容器宽度 |
154+
| `fadingEdge` | `boolean` | `false` | 是否开启上下边缘模糊效果 |
153155
| `prefix` | `string` | - | 静态前缀(不参与滚动动画) |
154156
| `suffix` | `string` | - | 静态后缀(不参与滚动动画) |
157+
| `numberFormat` | `Intl.NumberFormat` | - | 国际化格式化配置,对数字`value`进行Format |
155158
| `onAnimationEnd` | `() => void` | - | 动画结束回调(Vue: `@animation-end`|
156159

157-
### 内置字符列表
158160

159-
```ts
160-
import { TickerUtils } from './components/Ticker';
161+
### 🧩 字符集配置详解 (characterLists)
161162

162-
TickerUtils.provideNumberList() // '0123456789'
163-
TickerUtils.provideAlphabeticalList() // 'abc...zABC...Z'
163+
`characterLists` 是控制 Ticker 动画逻辑的核心配置。它接受一个字符串数组,数组的每一项代表一组**“可以互相滚动”**的字符。
164164

165-
### 🧩 字符集配置详解
165+
#### 预设常量 (Presets)
166+
为了方便使用,我们内置了常用的字符集常量:
166167

167-
`characterLists` 是控制 Ticker 动画逻辑的核心配置。它接受一个字符串数组,数组的每一项代表一组**“可以互相滚动”**的字符。
168+
```ts
169+
import { Presets } from '@tombcato/smart-ticker';
168170

169-
**基本规则:**
170-
1. **同组滚动**:如果旧字符和新字符在同一个字符串中(例如 `0``9``'0123456789'` 中),它们会产生滚动动画。
171-
2. **跨组替换**:如果它们不在同一组(例如 `a``1`),或者任何一个字符不在配置列表中(例如汉字),它们会原地切换(Switch),不会产生滚动。
171+
Presets.NUMBER // '0123456789'
172+
Presets.ALPHABET // 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
173+
Presets.ALPHANUMERIC // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
174+
Presets.CURRENCY // '0123456789.,'
175+
```
172176

173-
**配置技巧:**
177+
#### 配置规则
178+
1. **同组滚动**:如果旧字符和新字符在同一个字符串中(例如 `0``9``Presets.NUMBER` 中),它们会产生滚动动画。
179+
2. **跨组替换**:如果它们不在同一组(例如 `a``1`),或者任何一个字符不在配置列表中(例如汉字),它们会原地切换(Switch),不会产生滚动。
174180

175-
* **默认全字母**`TickerUtils.provideAlphabeticalList()` 默认包含 `a-z``A-Z`。如果你希望大小写之间可以滚动(如 `a` -> `A`),使用它即可。
176-
* **由于物理隔离**:如果你不希望小写字母滚动变成大写字母(希望它们直接切换),请将它们配置为两个独立的字符串,例如 `['abc...', 'ABC...']`
181+
#### 配置技巧
182+
* **常用场景**:直接使用 `Presets.ALPHANUMERIC` 即可支持绝大多数数字和字母的滚动。
183+
* **物理隔离**:如果你不希望小写字母通过滚动变成大写字母(希望它们直接淡入淡出切换),请将它们配置为两个独立的字符串:`[Presets.NUMBER, 'abc...', 'ABC...']`
177184

178-
**示例**
185+
**代码示例**
179186

180-
```javascript
181-
// 场景:数字、字母(大小写隔离)、符号
182-
characterLists={[
183-
'abcdefghijklmnopqrstuvwxyz', // 小写组
184-
'ABCDEFGHIJKLMNOPQRSTUVWXYZ', // 大写组
185-
'0123456789', // 数字组
186-
'.,!@#$%^&*' // 符号组
187-
]}
188-
```
187+
```tsx
188+
<Ticker
189+
value={val}
190+
characterLists={[
191+
Presets.NUMBER, // 数字组
192+
'abcdefghijklmnopqrstuvwxyz', // 小写组
193+
'ABCDEFGHIJKLMNOPQRSTUVWXYZ', // 大写组
194+
'.,!@#$%^&*' // 符号组
195+
]}
196+
/>
189197
```
190198

191199
## 💻 运行演示

README_EN.md

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
| | |
3030
| :--- | :--- |
3131
| **🌏 Multi-Charset Support**<br>Supports CJK, Numbers, Emojis, and mixed text rolling. Auto-adjusts spacing based on Unicode width. | **🧠 Smart Diff Animation**<br>Uses Levenshtein algorithm to find the shortest change path; identical characters remain static. |
32-
| **⚡ Smooth Interruption**<br>Seamlessly transitions to new targets if the value changes dynamically during animation. | **📈 Rich Motion**<br>Built-in `linear`, `bounce`, `easeInOut` easings. Supports `charWidth` for fine-tuning. |
33-
| **🦄 Dual Framework**<br>Provides both React (Hooks) and Vue 3 (Composition) components with a unified API. | **🚀 High Performance**<br>Powered by `RAF`, removing DOM overhead, optimized for high-frequency data streams. |
32+
| **⚡ Smooth Interruption**<br>Seamlessly transitions to new targets if the value changes dynamically during animation. | **📈 Rich Motion**<br>Built-in variety of easings.Supports custom easing function. Supports `charWidth` fine-tuning. |
33+
| **🦄 Dual Framework**<br>Provides both React (Hooks) and Vue 3 (Composition) components with a unified API. | **🚀 High Performance**<br>Powered by `RAF`, supporting **Auto-scale**, **Fading Edge**, and **Disable Animation**. |
3434

3535
## 📦 Installation
3636

@@ -138,50 +138,59 @@ The component uses the system monospace stack by default. To use a custom font (
138138

139139
| Prop | Type | Default | Description |
140140
|------|------|--------|------|
141-
| `value` | `string` | - | The text value to display (Required) |
141+
| `value` | `string`\|`number` | - | The text value to display (Required) |
142142
| `duration` | `number` | `500` | Animation duration (ms) |
143143
| `easing` | `EasingName \| function` | `'easeInOut'` | Easing: `linear`, `easeIn`, `easeOut`, `easeInOut`, `bounce`, or custom `(t: number) => number` |
144144
| `direction` | `string` | `'ANY'` | Scroll direction: `UP`, `DOWN`, `ANY` (shortest path) |
145145
| `charWidth` | `number` | `1` | Character width multiplier (base 0.8em) |
146146
| `characterLists` | `string[]` | `['0123456789']` | Allowed character sets |
147147
| `className` | `string` | `''` | Custom CSS class name |
148148
| `animateOnMount` | `boolean` | `false` | Animate on initial render |
149-
| `disabled` | `boolean` | `false` | Disable animation, show final value immediately |
149+
| `disableAnimation` | `boolean` | `false` | Disable animation, show final value immediately |
150+
| `autoScale` | `boolean` | `false` | Enable auto-scaling to fit container width |
151+
| `fadingEdge` | `boolean` | `false` | Enable top/bottom fading edge effect |
150152
| `prefix` | `string` | - | Static prefix (not animated) |
151153
| `suffix` | `string` | - | Static suffix (not animated) |
154+
| `numberFormat` | `Intl.NumberFormat` | - | Intl formatter number `value` |
152155
| `onAnimationEnd` | `() => void` | - | Callback when animation ends (Vue: `@animation-end`) |
153156

154-
### Built-in Character Lists
155157

156-
```ts
157-
import { TickerUtils } from './components/Ticker';
158+
### 🧩 Character Configuration (characterLists)
158159

159-
TickerUtils.provideNumberList() // '0123456789'
160-
TickerUtils.provideAlphabeticalList() // 'abc...zABC...Z'
160+
`characterLists` controls the core animation logic. It accepts an array of strings, where each string represents a group of characters that can **scroll into each other**.
161161

162-
### 🧩 Character Configuration
162+
#### Presets (Common Character Lists)
163+
For convenience, we provide built-in constants for common character sets:
163164

164-
`characterLists` controls the core animation logic. It accepts an array of strings, where each string represents a group of characters that can **scroll into each other**.
165+
```ts
166+
import { Presets } from '@tombcato/smart-ticker';
165167

166-
**Rules:**
167-
1. **Scroll**: If both the old and new characters belong to the same group string (e.g., `0` to `9` in `'0123456789'`), they will scroll.
168-
2. **Switch**: If they are in different groups, or if a character is not in any list (e.g., Chinese characters), they will switch instantly without scrolling.
168+
Presets.NUMBER // '0123456789'
169+
Presets.ALPHABET // 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
170+
Presets.ALPHANUMERIC // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
171+
Presets.CURRENCY // '0123456789.,'
172+
```
169173

170-
**Configuration Tips:**
174+
#### Animation Rules
175+
1. **Scroll**: If both the old and new characters belong to the same group string (e.g., `0` to `9` in `Presets.NUMBER`), they will scroll.
176+
2. **Switch**: If they are in different groups, or if a character is not in any list (e.g., Chinese characters), they will switch instantly (fade/flip) without scrolling.
171177

172-
* `TickerUtils.provideAlphabeticalList()` includes both `a-z` and `A-Z`.
173-
* To prevent scrolling between cases (e.g., `a` -> `A`), provide them as separate strings: `['abc...', 'ABC...']`.
178+
#### Configuration Tips
179+
* **Common Use Case**: Simply use `Presets.ALPHANUMERIC` to support most alphanumeric scrolling.
180+
* **Case Isolation**: To prevent scrolling between cases (e.g., `a` -> `A`), list them as separate groups: `[Presets.NUMBER, 'abc...', 'ABC...']`.
174181

175-
**Example:**
182+
**Code Example:**
176183

177-
```javascript
178-
characterLists={[
179-
'abcdefghijklmnopqrstuvwxyz', // Lowercase group
180-
'ABCDEFGHIJKLMNOPQRSTUVWXYZ', // Uppercase group
181-
'0123456789', // Number group
182-
'.,!@#$%^&*' // Symbol group
183-
]}
184-
```
184+
```tsx
185+
<Ticker
186+
value={val}
187+
characterLists={[
188+
Presets.NUMBER, // Numbers
189+
'abcdefghijklmnopqrstuvwxyz', // Lowercase Group
190+
'ABCDEFGHIJKLMNOPQRSTUVWXYZ', // Uppercase Group
191+
'.,!@#$%^&*' // Symbols
192+
]}
193+
/>
185194
```
186195

187196
## 💻 Running Demos

0 commit comments

Comments
 (0)