* 更新活跃单元 * @param {number} unitIndex - 单元索引 * @param {Object} [options={}] - 选项
(unitIndex, options = {})
| 370 | * @param {Object} [options={}] - 选项 |
| 371 | */ |
| 372 | updateActiveUnit(unitIndex, options = {}) { |
| 373 | const { shouldScrollUnitIntoView = false } = options; |
| 374 | |
| 375 | if (this.dom.unitList) { |
| 376 | qsa('.unit-item', this.dom.unitList).forEach((item, index) => { |
| 377 | toggleClass(item, 'active', index === unitIndex); |
| 378 | }); |
| 379 | |
| 380 | const activeItem = qs(`.unit-item[data-unit-index="${unitIndex}"]`, this.dom.unitList); |
| 381 | if (activeItem && shouldScrollUnitIntoView) { |
| 382 | activeItem.scrollIntoView({ block: 'center', inline: 'nearest' }); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | if (this.dom.unitSelect) { |
| 387 | this.dom.unitSelect.value = unitIndex; |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | // ========================================================================= |
| 392 | // 歌词管理 |
no test coverage detected