473,804 Members | 4,181 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scroll Jerking - smoothScroll?

8 New Member
Hello. I have slight issue. I have been just seeing what java can do. The code below shows a basic html text file with a highlighted bar that scrolls over each <tr>. If you notice, when you scroll using your up/down arrow the page jerks. Would I remove this jerking by applying smoothScroll? Thank you in advance for your help.

Expand|Select|Wrap|Line Numbers
  1. <Head>
  2. <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
  3. <title>test_1</title>
  4. <style type="text/css">
  5.   .tableExample{border-collapse: collapse; border: 0px solid black; overflow: auto; }
  6.   .tableExample tr td{cursor:pointer; border: 0px solid black; padding: 0px;}
  7.   .odd{background-color:#F5DEB3';}
  8.   .even{background-color:#F5DEB3';}
  9.   .high{background-color:#FFFF00;font-size:medium;font-weight:bold;position: fixed;}
  10.   .selected{background-color:#FFFF00;font-size:medium;font-weight:bold;}
  11. </style>
  12.  
  13. <script type="text/javascript">
  14. var table = {};
  15.  
  16. table.keys = {
  17.     AddNew : function(id,action){
  18.         this.monitorActions[id] = action;
  19.         this.quickLookup.push(id);
  20.     },
  21.     monitorActions : new Array(),
  22.     quickLookup : new Array()
  23. }
  24.  
  25. table.ActiveTable = null;
  26.  
  27. table.SelectableLSPEC = function(tableId,activate){
  28.     var ref = this;
  29.     this.tableId = tableId; 
  30.     this._init();
  31.     this.selectedId = null;
  32.     table.keys.AddNew(tableId,ref);
  33.     if(activate){
  34.         table.ActiveTable = tableId;
  35.         this.selectFirst();
  36.     }
  37. }
  38.  
  39. table.SelectableLSPEC.prototype._init = function(){
  40.     var ref = this;
  41.     var elemTable = document.getElementById(this.tableId);
  42.     var rows = elemTable.getElementsByTagName("tr");
  43.     var cnt = rows.length;
  44.     for(var i=0; i<cnt;i++){
  45.         var className = (i%2)?"odd":"even";
  46.         rows[i].className = className;
  47.         rows[i].defaultClassName = className;
  48.         rows[i].onmouseover = function(){if(this.className!="selected")this.className="high";}
  49.         rows[i].onmouseout = function(){if(this.className!="selected")this.className=this.defaultClassName; }
  50.         rows[i].onclick = function(){ref.select(this)}; 
  51.     }
  52.     ElemTable = null;rows=null;
  53. }
  54.  
  55. table.SelectableLSPEC.prototype.select = function(elem){
  56.     this.removeSlections();
  57.     this.selectedId = (this.selectedId!=elem.id)?elem.id:null;
  58.     if(this.selectedId!=null)elem.className = "selected";
  59. }
  60.  
  61. table.SelectableLSPEC.prototype.removeSlections = function(elem){
  62.     var elemTable = document.getElementById(this.tableId);
  63.     var rows = elemTable.getElementsByTagName("tr");
  64.     var cnt = rows.length;
  65.     for(var i=0; i<cnt;i++)rows[i].className = rows[i].defaultClassName;
  66.         ElemTable=null; rows=null;
  67.     }
  68.  
  69.     table.SelectableLSPEC.prototype.selectFirst = function(){
  70.  
  71.     var elemTable = document.getElementById(this.tableId);
  72.     var firstRow = elemTable.getElementsByTagName("tr")[0];
  73.     firstRow.className = "selected"
  74.     this.selectedId = firstRow.id;
  75.     ElemTable=null; firstRow=null;
  76.  
  77. }
  78.  
  79. table.SelectableLSPEC.prototype.keyClick = function(keyCode){
  80.     var direction;
  81.     switch (keyCode) {
  82.         case 38:
  83.             direction = -1;
  84.         break;
  85.         case 40:
  86.             direction = 1;
  87.         break;
  88.         default:
  89.             direction = 0;
  90.         break;
  91.     }
  92.     if(direction!=0){ 
  93.     this.selectNext(direction);
  94.  
  95.     document.scrollTop = hilightedElement.offsetTop;    
  96.     }
  97. }
  98.  
  99. table.SelectableLSPEC.prototype.selectNext = function(dir){
  100.  
  101.     var elemTable = document.getElementById(this.tableId);
  102.     var rows = elemTable.getElementsByTagName("tr");
  103.     var cnt = rows.length;
  104.     var hasSelection = false;
  105.     for(var i=0; i<cnt;i++){
  106.         if(rows[i].className == "selected"){
  107.             if((dir==-1 && i>0) || (dir==1 && i+1<cnt)){
  108.                 rows[i].className = rows[i].defaultClassName;
  109.                 rows[i+dir].className = "selected";
  110.                 this.selectedId = rows[i+dir].id;
  111.                 rows[i+dir].scrollIntoView(dir == -1);
  112.             }
  113.             hasSelection = true;
  114.             break;
  115.         }
  116.     }
  117.  
  118.     ElemTable=null; rows=null;
  119.  
  120. }
  121.  
  122.  
  123.  
  124. function monitorClick(e){
  125.     var evt = (e)?e:event;
  126.  
  127.     var theElem = (evt.srcElement)?evt.srcElement:evt.target;
  128.  
  129.     while(theElem!=null){
  130.         if(table.keys.quickLookup.indexOf(theElem.id) != -1){
  131.             table.ActiveTable = theElem.id;
  132.             return true;
  133.         }
  134.         theElem = theElem.offsetParent; 
  135.     }
  136.     table.ActiveTable = null;
  137.     return true;
  138. }
  139.  
  140.  
  141. function handleKeyPress(e){
  142.     var code;
  143.     if (window.event)  {
  144.         code = window.event.keyCode;
  145.         event.cancelBubble = true;
  146.     } else if (e) {
  147.         code = e.which;
  148.         e.stopPropagation();
  149.     }
  150.     if(table.ActiveTable){
  151.         table.keys.monitorActions[table.ActiveTable].keyClick(code);
  152.     }
  153.     return false;
  154. }
  155.  
  156. document.onclick = monitorClick;
  157. document.onkeydown = handleKeyPress;
  158.  
  159.  
  160. var table1 = null;
  161. window.onload = function(){
  162.     table1 = new table.SelectableLSPEC("tableExample1",true)
  163. }
  164.  
  165. </script> 
  166. </head>
  167. <body>
  168. <form id="form1" runat="server">
  169. <div>
  170. <table class="tableExample" id="tableExample1">
  171.  
  172. <tr id="i1_0"><td> <span class='BigFont'>Test Code</Span>Test Code<br></td>
  173. <tr id="i2_0"><td>........................................................................<br></td></tr>
  174. <tr id="i3_0"><td>..............Test Code.......Test Code......Test Code.......<br></td></tr>
  175. <tr id="i4_0"><td>..............TEst................................................<br></td></tr>
  176.  
  177. <tr id="i5_0"><td>........................................................................<br></td></tr>
  178. <tr id="i6_0"><td>Test Code<br></td></tr>
  179. <tr id="i7_0"><td>........................................................................<br></td></tr>
  180. <tr id="i8_0"><td>Test Code<br></td></tr>
  181. <tr id="i9_0"><td>Test Code<br></td></tr>
  182. <tr id="i10_0"><td>Test Code<br></td></tr>
  183. <tr id="i11_0"><td>Test Code<br></td></tr>
  184. <tr id="i12_0><td>........................................................................<br></td></tr>
  185. <tr id="i177_0"><td>........................................................................<br></td></tr>
  186. <tr id="i18_0"><td>Test Code<br></td></tr>
  187. <tr id="i19_0"><td>Test Code<br></td></tr>
  188. <tr id="i20_0"><td>Test Code<br></td></tr>
  189. <tr id="i21_0"><td>Test Code<br></td></tr>
  190. <tr id="i22_0"><td>Test Code<br></td></tr>
  191. <tr id="i23_0"><td>Test Code<br></td></tr>
  192. <tr id="i24_0"><td>Test Code<br></td></tr>
  193. <tr id="i25_0"><td>Test Code<br></td></tr>
  194. <tr id="i26_0"><td>Test Code<br></td></tr>
  195. <tr id="i266_0"><td>........................................................................<br></td></tr>
  196. <tr id="i27_0"><td>Test Code<br></td></tr>
  197. <tr id="i28_0"><td>Test Code<br></td></tr>
  198. <tr id="i29_0"><td>Test Code<br></td></tr>
  199. <tr id="i30_0"><td>Test Code<br></td></tr>
  200. <tr id="i300_0"><td>........................................................................<br></td></tr>
  201. <tr id="i31_0"><td>Test Code<br></td></tr>
  202. <tr id="i32_0"><td>Test Code<br></td></tr>
  203. <tr id="i33_0"><td>........................................................................<br></td></tr>
  204. <tr id="i34_0"><td>Test Code<br></td></tr>
  205. <tr id="i35_0"><td>Test Code<br></td></tr>
  206. <tr id="i355_0"><td>........................................................................<br></td></tr>
  207. <tr id="i36_0"><td>Test Code<br></td></tr>
  208. <tr id="i37_0"><td>Test Code<br></td></tr>
  209. <tr id="i38_0"><td>Test Code<br></td></tr>
  210. <tr id="i388_0"><td>........................................................................<br></td></tr>
  211. <tr id="i39_0"><td>Test Code<br></td></tr>
  212. <tr id="i40_0"><td>Test Code<br></td></tr>
  213. <tr id="i41_0"><td>Test Code<br></td></tr>
  214. <tr id="i42_0"><td>Test Code<br></td></tr>
  215. <tr id="i43_0"><td>Test Code<br></td></tr>
  216. <tr id="i44_0"><td>Test Code<br></td></tr>
  217. <tr id="i45_0"><td>Test Code<br></td></tr>
  218. <tr id="i46_0"><td>Test Code<br></td></tr>
  219. <tr id="i47_0"><td>Test Code<br></td></tr>
  220. <tr id="i48_0"><td>Test Code<br></td></tr>
  221. <tr id="i49_0"><td>Test Code<br></td></tr>
  222. <tr id="i50_0"><td>Test Code<br></td></tr>
  223. <tr id="i51_0"><td>Test Code<br></td></tr>
  224. <tr id="i52_0"><td>Test Code<br></td></tr>
  225. <tr id="i53_0"><td>Test Code<br></td></tr>
  226. </table>
  227. </body>
  228. </html>
  229.  
  230.  
  231. </table>
  232. </BODY>
  233. </HTML>
  234.  
Mar 20 '08 #1
0 1345

Sign in to post your reply or Sign up for a free account.

Similar topics

12
12747
by: Arlie Rahn | last post by:
I would like to ad a custom scroll bar control to my app that has a customizable and "flat" look to it (not the normal VB look). Does anyone have any ideas on where to find a good one?
4
3657
by: ojorus | last post by:
Hi! I just wonder how I can save a page's scroll position with javascript. (i'm not a javascript developer) I have a PHP-page with two columns; the left contains a lot of thumbnails, and the right contain a bigger picture of the thumbnailed selected. The problem is that all these thumbnails (and the big picture) are placed quite far down in the document. (a lot of text is at the top.) What I want is that when a thumbnail is clicked, the...
8
3775
by: ergobob | last post by:
Hello, I have two scroll boxes on the same page. The first scroll box is good in IE but the words will not wrap correctly in Firefox. The second scroll box is good in all browsers. You can see this on a test page at http://www.usernomics.com/ergonomic-products-accessories5.html . Can anyone see why the words will not wrap correctly in the first scroll box
3
3995
by: Devonish | last post by:
I have a form designed as a Continuous form which displays one record per line. Taking account of the header and footer and the size of the screen, I can display 30 records at a time. I can see other records by scrolling up or down with either the scroll bar on the right of the screen, or the up and down arrows which are above and below this scroll bar; or I can use the scroll wheel
6
4324
by: Mike Johnson | last post by:
I have a ListView on a form, I'm displaying the items as a list. The Scroll is set to true. I want to know how can I set the scroll bar to Vertical?
6
10709
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm using the VScrollBar and set it as follow: m_vScrollBar.Minimum = -19602; m_vScrollBar.Maximum = 0; m_vScrollBar.SmallChange = 1; m_vScrollBar.LargeChange = 1089; m_vScrollBar.Value = m_vScrollBar.Maximum; The scroll bar is set to start from the bottom.
2
1859
by: Msleh08 | last post by:
Hello. The code below shows a basic html text file with a highlighted bar that scrolls over each <tr> using your up/down arrow. If you notice, when you scroll using your up/down arrow the page jerks. How would I remove the jerking? Also, when the highlighted bar reaches close to the bottom it shows a few lines that are to come. Is there a way in Javascript that I show more lines after the higlighted bar? Thank you in advance for your help. :o) ...
12
7890
Frinavale
by: Frinavale | last post by:
I think I'm trying to do something impossible. I have a <div> element with a overflow style set to "scroll". In other words my <div> element allows the user to scroll the content within it. There are a number of elements within this <div> that cause the <div> to participate in an Ajax call to the server. In order to maintain the scroll position of the <div> during the Ajax request I store the scroll value in a hidden field so that when...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10076
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.