Solved

Smooth Horizontal List Scroll

Posted on 2007-03-19
5
514 Views
Last Modified: 2008-02-20
I've been trying to figure out how to do a smooth scrolling horizontal list with javascript for a while now and I just noticed that the EE menu bar does exactly what I am trying to do (when you click the "More" link). Looking through the source code I couldn't really figure out how they were achieving it. Does anybody know how I can do this effect?

Basically I need to be able to scroll through a horizontal list on the push of a button so that new items come into view. Exactly how they do it here on EE.
0
Comment
Question by:jfredrickson
  • 4
5 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 18754570
Running the risk of getting the standards people on my back:
FF and IE both support the marquee tag
Since it is just html, all things in the marquee are accessible to the browser and to search engines

Here is an alas IE only (unless I can find out how to code onBounce for FF)

<a href="#" onClick="document.getElementById('m1').direction='left'; document.getElementById('m1').start(); return false"><<</a>|
<marquee id="m1" scrollamount="10" onClick="this.stop()" onBounce="this.stop()" behavior="alternate" direction="right" width="75%">
[<a href="">Link01</a>]
[<a href="">Link02</a>]
[<a href="">Link03</a>]
[<a href="">Link04</a>]
[<a href="">Link05</a>]
[<a href="">Link06</a>]
[<a href="">Link07</a>]
[<a href="">Link08</a>]
[<a href="">Link09</a>]
[<a href="">Link10</a>]
[<a href="">Link11</a>]
[<a href="">Link12</a>]
[<a href="">Link13</a>]
[<a href="">Link14</a>]
[<a href="">Link15</a>]
[<a href="">Link16</a>]
[<a href="">Link17</a>]
[<a href="">Link18</a>]
[<a href="">Link19</a>]
[<a href="">Link20</a>]
</marquee>|
<a href="#" onClick="document.getElementById('m1').direction='right'; document.getElementById('m1').start(); return false">>></a>
0
 
LVL 4

Author Comment

by:jfredrickson
ID: 18767910
Would it be possible to get something that doesn't bounce around but just sits there like normal and only scrolls when you click the button? I am looking for the exact functionality of the categories menu at the top of the EE page.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 18771101
That is not smooth scrolling it is showing and hiding

function ToggleList(zonePosition)
{
  this.first = document.getElementById('compZnNavF');
  this.second  = document.getElementById('compZnNavL');
  this.cont = document.getElementById('compZnNavCont');
  if(zonePosition == 1)
  {
     this.second.className = 'hide';
     this.first.className = '';
     this.cont.className = 'next';
  }
  else
  {
     this.first.className = 'hide';
     this.second.className = '';
     this.cont.className = '';
  }

  this.toggleNavs = function() {
    if(this.first.className == 'hide')
    {
       this.second.className = 'hide';
       this.first.className = '';
       this.cont.className = 'next';
    }
    else
    {
       this.first.className = 'hide';
       this.second.className = '';
       this.cont.className = '';
    }
  }
}

0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 18771118
<div id="compZnNav"><a id="compZnNavCont" class="next" onmouseup="toggleList.toggleNavs()"></a><div id="compZnNavCl"><ul id="compZnNavF">

<li class="firstChild" id="r5297"><span class=" root5297"><a href="/Microsoft/"><span>Microsoft</span></a></span></li>
<li class="nCur" id="r5349"><span class=" root5349"><a href="/Apple/"><span>Apple</span></a></span></li>
<li class="nCur" id="r5374"><span class=" root5374"><a href="/Internet/"><span>Internet</span></a></span></li>
<li class="nCur" id="r5624"><span class=" root5624"><a href="/Gamers/"><span>Gamers</span></a></span></li>
<li class="nCur" id="r5375"><span class=" root5375"><a href="/Digital_Living/"><span>Digital Living</span></a></span></li>
<li class="nCur" id="r5377"><span class=" root5377"><a href="/Virus_and_Spyware/"><span>Virus &amp; Spyware</span></a></span></li>
<li class="nCur" id="r5625"><span class=" root5625"><a href="/Hardware/"><span>Hardware</span></a></span></li>
<li class="nCur" id="r3062"><span class=" root3062"><a href="/Software/"><span>Software</span></a></span></li>

<li class="nCur" id="r5379"><span class=" root5379"><a href="/ITPro/"><span>ITPro</span></a></span></li>
<li class="nCur" id="r5380"><span class=" root5380"><a href="/Developer/"><span>Developer</span></a></span></li>
</ul><ul id="compZnNavL"><li class="nCur" id="r5381"><span class=" root5381"><a href="/Storage/"><span>Storage</span></a></span></li>
<li class="nCur" id="r5382"><span class=" root5382"><a href="/OS/"><span>OS</span></a></span></li>
<li class="nCur" id="r5383"><span class=" root5383"><a href="/Database/"><span>Database</span></a></span></li>
<li class="nCur" id="r5384"><span class=" root5384"><a href="/Security/"><span>Security</span></a></span></li>
<li class="current" id="r5628"><span class=" root5628"><a href="/Programming/"><span>Programming</span></a></span></li>
<li class="nCur" id="r5385"><span class=" root5385"><a href="/Web_Development/"><span>Web Development</span></a></span></li>
<li class="nCur" id="r5626"><span class=" root5626"><a href="/Networking/"><span>Networking</span></a></span></li>

<li class="nCur" id="r5627"><span class=" root5627"><a href="/Other/"><span>Other</span></a></span></li>
</ul></div></div>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 18771134
and the stylesheet
#compZnNavCont{float:right;position:relative;margin-right:1px;margin-bottom:10px;background-repeat:no-repeat;width:2%;height:25px;display:block;cursor:pointer;background-image:url(/expert/images/zonePrev.gif);background-position:0 7px;z-index:2}
#compZnNav .next{background-image:url(/expert/images/zoneNext.gif)}
#compZnNav{top:64px;margin:0;position:absolute;width:100%;height:26px;white-space:nowrap;background:url(/expert/images/zoneNav.gif) repeat-x;padding:0}
.IE #compZnNav{position:relative;top:-32px}
#compZnNav UL{margin:0;height:26px;position:relative;clear:none;overflow:hidden}
#compZnNav #compZnNavL{background:url(/expert/images/zoneNav.gif) repeat-x;position:relative;height:26px}
#compZnNav .hide{display:none}
#compZnNav LI{background:url(/expert/images/zoneDivider.gif) 100% 100% no-repeat;display:block;margin:0;float:left;padding:0 1px 0 0;height:26px;width:auto;text-align:center}
#compZnNav LI SPAN{line-height:16px}
#compZnNav #r5297{width:10%}
#compZnNav #r5349{width:8%}
#compZnNav #r5374{width:10%}
#compZnNav #r5624{width:9%}
#compZnNav #r5375{width:12%}
#compZnNav #r5377{width:14%}
#compZnNav #r5625{width:9%}
#compZnNav #r3062{width:9%}
#compZnNav #r5379{width:7%}
#compZnNav #r5380{width:10%}
#compZnNav #r5381{width:10%}
#compZnNav #r5382{width:7%}
#compZnNav #r5383{width:10%}
#compZnNav #r5384{width:10%}
#compZnNav #r5628{width:11%}
#compZnNav #r5385{width:14%}
#compZnNav #r5626{width:10%}
#compZnNav #r5627{width:7%}
#compZnNav LI A, #compZnNav LI A:hover{display:block;text-decoration:none;overflow:hidden;height:10px;padding:5px 0 10px 0}
#compZnNav .current A{background:url(/expert/images/zoneNavCurrent.gif) repeat-x}
#compZnNav LI A SPAN{font-weight:bold;font-size:11px;color:#ffffff}
#compZnNav LI A:hover{text-decoration:none}
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question