1 define('scrollbar', ['jquery'], 
  2     function ( $ ) {
  3    		/**
  4 		 * A Class to handle the workbook scroll - once the scroll is happened it will load the current view sheet cell contents.
  5 		 * @name scrollbar
  6 		 * @class scrollbar
  7 		 * @example require('scrollbar')
  8 		 * @exports scrollbar
  9 		 * @version 1.0
 10 		 * @module scrollbar
 11 		 * @augments jquery
 12 		 **/
 13         var scrollbar = {
 14         	/**
 15 			 * @name registerScrollListener
 16 			 * @memberOf scrollbar
 17 			 * @method 
 18 			 * @description For the scroll listener, this method should be called on workbook setup. This function will create the event listener for the DIV around teh datatable on scroll event.
 19 			 * @function
 20 			 */
 21             registerScrollListener:function(){
 22                	//$(Nexcel.DOM_OBJ.dataTableDiv).scroll
 23 				$('.dataTableDiv').scroll(function(e){
 24 					var sum = 0;
 25 					$('nav').each(function(){sum+=$(this).height() || 0;});
 26 					$('.rowTableDiv').css('top',(sum + 2 - $(this).scrollTop()));
 27 					$('.colsHeaderDiv').css('left',-1 * $(this).scrollLeft());
 28 					
 29 					
 30 					var WorkBook=require('WorkBook');
 31 					var diff = WorkBook.LAST_TOP - $(this).scrollTop();
 32 					var tableRows = $('#dataTable tr');
 33 					var lastRowViewPos = $(tableRows[tableRows.length-1]).position().top;
 34 					//console.log(lastRowViewPos +"   Scroll Top :"+$(this).scrollTop() +" Final DIFF:"+(lastRowViewPos-$(this).scrollTop()) +" DIV H:"+$(this).height());
 35 					$(DomObjects.rowNumTableDiv).scrollTop($(this).scrollTop());
 36 					$(DomObjects.columnNameDiv).scrollLeft($(this).scrollLeft());
 37 					if(WorkBook.LAST_LEFT != $(this).scrollLeft() || WorkBook.LAST_TOP !=  $(this).scrollTop()){
 38 						WorkBook.LAST_LEFT = $(this).scrollLeft();
 39 						WorkBook.LAST_TOP = $(this).scrollTop();
 40 						require('GridView').rePositionGroupHeaderDiv();
 41 					}
 42 					if(parseInt(1.5*$(this).height())<(lastRowViewPos-$(this).scrollTop()))// Means there are enough Data in table to present while scrolling..
 43 						return;
 44 					require('GridView').loadRowData(diff);
 45 					//WorkBook.LAST_TOP = $(this).scrollTop();
 46 					
 47 					// Moving the group header in body according to the Horizontal scroll bar.
 48 					
 49 					
 50 					//TODO Implement the following code for scrolling...
 51 					//Nexcel.CONTEXT_MENU.closeMenu();
 52 					
 53 					//TODO on Scroll add the Rows and Cols header as required.
 54 						
 55 				});
 56             }
 57         };
 58  
 59         return scrollbar;
 60 });