Merge pull request #129 from yuvipanda/channel-nav-wraparound

Wrap around when using cmd+up / cmd+down to navigate channels
This commit is contained in:
Mattias Erming 2014-09-13 23:28:25 +02:00
commit 881a5badb9
1 changed files with 6 additions and 2 deletions

View File

@ -507,11 +507,15 @@ $(function() {
var direction = keys.split("+").pop();
switch (direction) {
case "up":
channels.eq(Math.max(0, index - 1)).click();
// Wrap around!
var upTarget = (channels.length + (index - 1 + channels.length)) % channels.length;
channels.eq(upTarget).click();
break;
case "down":
channels.eq(Math.min(channels.length, index + 1)).click();
// Wrap aroud!
var downTarget = (channels.length + (index + 1 + channels.length)) % channels.length;
channels.eq(downTarget).click();
break;
}
});