From 4e04e4954f7a29cbf38f983c60cb17eca07bf13b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 12 Sep 2012 03:23:34 -0400 Subject: [PATCH] moved calling api scrollIntoViewIfNeeded to setCurrentFile --- client.js | 5 ++++- lib/client/keyBinding.js | 27 ++++++++++----------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/client.js b/client.js index 96ec3bac..5e8c6fb4 100644 --- a/client.js +++ b/client.js @@ -661,7 +661,10 @@ CloudClient.Util = (function(){ if(lCurrentFileWas) this.unSetCurrentFile(lCurrentFileWas); - pCurrentFile.className = CloudCommander.CURRENT_FILE; + pCurrentFile.className = CloudCommander.CURRENT_FILE; + + /* scrolling to current file */ + Util.scrollIntoViewIfNeeded(pCurrentFile); return lRet_b; }; diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index 2c07e5be..05fc2d45 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -160,10 +160,7 @@ var CloudCommander; lCurrentFile = lCurrentFile.previousSibling; if(lCurrentFile){ /* выделяем предыдущую строку*/ - Util.setCurrentFile(lCurrentFile); - - /* scrolling to current file*/ - Util.scrollIntoViewIfNeeded(lCurrentFile); + Util.setCurrentFile(lCurrentFile); } event.preventDefault();//запрет на дальнейшее действие @@ -179,9 +176,6 @@ var CloudCommander; if(lCurrentFile){ /* выделяем следующую строку*/ Util.setCurrentFile(lCurrentFile); - - /* scrolling to current file*/ - Util.scrollIntoViewIfNeeded(lCurrentFile); event.preventDefault();//запрет на дальнейшее действие } @@ -199,10 +193,10 @@ var CloudCommander; lCurrentFile = lCurrentFile. parentElement.firstChild; - Util.setCurrentFile(lCurrentFile); - - /* move scrollbar to top */ - lCurrentFile.scrollIntoView(); + /* set current file and + * move scrollbar to top + */ + Util.setCurrentFile(lCurrentFile); event.preventDefault();//запрет на дальнейшее действие } @@ -215,12 +209,11 @@ var CloudCommander; lCurrentFile = lCurrentFile. parentElement.lastElementChild; - Util.setCurrentFile(lCurrentFile); - - /* move scrollbar to bottom*/ - lCurrentFile.scrollIntoView(); - - event.preventDefault();//запрет на дальнейшее действие + /* set current file and + * move scrollbar to bottom + */ + Util.setCurrentFile(lCurrentFile); + event.preventDefault();//запрет на дальнейшее действие } /* если нажали клавишу page down