diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index 0a9a29b8..805d7bf2 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -4,7 +4,7 @@ CloudCommander.keyBinding=(function(){ "use strict"; var key_event=function(event){ var lCurrentFile; - var lName; + var lName, lTop; /* если клавиши можно обрабатывать*/ if(CloudCommander.keyBinded){ /* если нажали таб: @@ -38,13 +38,16 @@ CloudCommander.keyBinding=(function(){ /* и выделяем предыдущую строку*/ lCurrentFile.previousSibling.className = CloudCommander.CURRENT_FILE; - /* if we on the bootom of + /* if we on the top of * the screan then * moving down the scroolbar */ - var lTop = lCurrentFile.previousSibling.offsetTop; - lTop%CloudCommander.HEIGHT < 10 && - lCurrentFile.parentElement.scrollBy(2); + lTop = lCurrentFile.previousSibling.offsetTop; + console.log(lTop); + lTop % + (CloudCommander.HEIGHT - + CloudCommander.HEIGHT/10) < 70 && + lCurrentFile.parentElement.scrollByLines(-2); event.preventDefault(); } @@ -62,7 +65,20 @@ CloudCommander.keyBinding=(function(){ lCurrentFile.className=''; /* выделяем следующую строку*/ lCurrentFile.nextSibling.className = CloudCommander.CURRENT_FILE; - console.log(lCurrentFile.nextSibling.offsetTop); + + /* if we on the bottom of + * the screan then + * moving down the scroolbar + */ + lTop = lCurrentFile.previousSibling.offsetTop; + var lHeight = CloudCommander.HEIGHT; + var lMod = lTop % (lHeight - lHeight/10) < 70; + lTop > (lHeight/10) && + lMod < 70 && lMod > 50 && + console.log(lCurrentFile + .parentElement + .scrollByLines(2) || '!'); + event.preventDefault(); } }