* 添加输入框动画效果
(element: HTMLElement, animationType: 'translating' | 'success' | 'error')
| 898 | * 添加输入框动画效果 |
| 899 | */ |
| 900 | function addInputBoxAnimation(element: HTMLElement, animationType: 'translating' | 'success' | 'error'): void { |
| 901 | // 如果禁用了动画,则不添加动画效果 |
| 902 | if (!config.animations) { |
| 903 | return; |
| 904 | } |
| 905 | |
| 906 | // 移除已存在的动画类 |
| 907 | element.classList.remove('fluent-input-translating', 'fluent-input-success', 'fluent-input-error'); |
| 908 | |
| 909 | // 添加新的动画类 |
| 910 | element.classList.add(`fluent-input-${animationType}`); |
| 911 | |
| 912 | // 如果不是翻译中的动画,在动画完成后移除类 |
| 913 | if (animationType !== 'translating') { |
| 914 | setTimeout(() => { |
| 915 | element.classList.remove(`fluent-input-${animationType}`); |
| 916 | }, animationType === 'success' ? 1000 : 600); |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | /** |
| 921 | * 专门用于输入框翻译的微软翻译函数(不使用缓存) |
no outgoing calls
no test coverage detected