From fb9f8dd4499db34120317bcd70aca974e50c437a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 7 Aug 2012 10:47:43 -0400 Subject: [PATCH] added moving scrolling by cursor ability --- ChangeLog | 1 + lib/client/keyBinding.js | 42 ++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f66643b..857a91e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ End buttons pressed. * Added ability to move with Page Up and Page Down buttons. +* Added moving scrolling by cursor ability. 2012.08.06, Version 0.1.5 diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index ae5f69ea..8321cc58 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -77,7 +77,7 @@ CloudCommander.keyBinding=(function(){ /* если ненайдены выделенные файлы - выходим*/ if(!lCurrentFile) return; - + /* если это строка существет и * если она не заголовок * файловой таблицы @@ -87,17 +87,24 @@ CloudCommander.keyBinding=(function(){ /* убираем выделение с текущего элемента */ lCurrentFile.className=''; /* и выделяем предыдущую строку*/ - lCurrentFile.previousSibling.className = CloudCommander.CURRENT_FILE; + lCurrentFile.previousSibling.className = + CloudCommander.CURRENT_FILE; + + /* scrolling to current file*/ + if(lCurrentFile.previousSibling) + lCurrentFile.previousSibling.scrollIntoViewIfNeeded(); /* if we on the top of * the screan then * moving down the scroolbar */ - lTop = lCurrentFile.previousSibling.offsetTop; - lTop % - (CloudCommander.HEIGHT - - CloudCommander.HEIGHT/10) < 70 && - lCurrentFile.parentElement.scrollByLines(-2); + /* + lTop = lCurrentFile.previousSibling.offsetTop; + lTop % + (CloudCommander.HEIGHT - + CloudCommander.HEIGHT/10) < 70 && + lCurrentFile.parentElement.scrollByLines(-2); + */ } } /* если нажали клавишу в низ*/ @@ -115,18 +122,23 @@ CloudCommander.keyBinding=(function(){ /* выделяем следующую строку*/ lCurrentFile.nextSibling.className = CloudCommander.CURRENT_FILE; + /* scrolling to current file*/ + lCurrentFile.scrollIntoViewIfNeeded(); + /* 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) || '!'); + /* + 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) || '!'); + */ } } /* если нажали клавишу Home