(type: 'translate' | 'restore')
| 147 | |
| 148 | // 悬浮球动画效果 |
| 149 | function addFloatingBallAnimation(type: 'translate' | 'restore') { |
| 150 | if (!floatingBallInstance) return; |
| 151 | |
| 152 | const ball = floatingBallInstance.element; |
| 153 | const originalBackground = ball.style.background; |
| 154 | const originalTransition = ball.style.transition; |
| 155 | |
| 156 | // 设置过渡效果 |
| 157 | ball.style.transition = 'all 0.3s ease'; |
| 158 | |
| 159 | // 根据类型设置不同动画 |
| 160 | if (type === 'translate') { |
| 161 | // 翻译激活动画 |
| 162 | ball.style.transform = 'scale(1.2)'; |
| 163 | ball.style.boxShadow = '0 0 15px rgba(0, 128, 255, 0.8)'; |
| 164 | ball.style.background = '#4285f4'; |
| 165 | } else { |
| 166 | // 恢复原文动画 |
| 167 | ball.style.transform = 'scale(1.2)'; |
| 168 | ball.style.boxShadow = '0 0 15px rgba(76, 175, 80, 0.8)'; |
| 169 | ball.style.background = '#4caf50'; |
| 170 | } |
| 171 | |
| 172 | // 恢复原状 |
| 173 | setTimeout(() => { |
| 174 | if (!floatingBallInstance) return; |
| 175 | ball.style.transform = ''; |
| 176 | ball.style.boxShadow = ''; |
| 177 | ball.style.background = originalBackground; |
| 178 | |
| 179 | // 恢复原来的过渡设置 |
| 180 | setTimeout(() => { |
| 181 | if (floatingBallInstance) { |
| 182 | ball.style.transition = originalTransition; |
| 183 | } |
| 184 | }, 300); |
| 185 | }, 300); |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * 保存配置到存储 |
nothing calls this directly
no outgoing calls
no test coverage detected