Browse files

Fix resetting keyboard cursor.

This could lose the visual indicator in some cases.
  • Loading branch information...
1 parent c40e685 commit 934c843de7ade4c84ee8215bf2654f4004731eb1 @miracle2k committed May 21, 2012
Showing with 9 additions and 4 deletions.
  1. +9 −4 app/js/lyrics.js
View
13 app/js/lyrics.js
@@ -404,10 +404,15 @@ LyricsBox.prototype._assignTime = function(index) {
*/
LyricsBox.prototype.setKeyboardCursorIndex = function(index) {
// Validate the incoming value. If no index is given, reset to 0.
- index = (index == undefined) ? 0 : index;
- index = Math.max(0, Math.min(index, this.lyrics.length-1));
- if (index == this.keyboardCursorIndex)
- return;
+ // The key behind this construct is that if index == undefined, the
+ // 'has the value changed check' below is not run.
+ if (index == undefined)
+ index = 0
+ else {
+ index = Math.max(0, Math.min(index, this.lyrics.length-1));
+ if (index == this.keyboardCursorIndex)
+ return;
+ }
// Clear the old cursor
var spans = this.container.find('span');

0 comments on commit 934c843

Please sign in to comment.