- Create Account

News-Type Scroller

Forums > Inline HV Scrollbox > News-Type Scroller
Author
Message

1) Garison Piatt Group: Guests
IP: 24.25.--.--
I'm working on converting your HV Scroller into a news-style scroller, with automatic wraparound, and pausing on mouseovers. I'm doing this because the news scroller I wrote myself doesn't work on a Mac (not that this bothers me, but my clients care, for some reason). I could borrow a Mac and play around with it myself, but it's far me economical for me to use your brain instead.

So, this is what I've come up with:
function ilsAutoScroll(xDiff, yDiff) { with (this) {
if (!pageName || !isDyn)  return;

 if (timer) { clearInterval(timer);  timer = null }
 var divW = div.w();
 var divH = isOp?div.sty.pixelHeight:div.h();

 asCmd  =
  'with ('+myName+') {'+
 'xSpeed='+xDiff+';'+
   'ySpeed='+yDiff+';'+
   'if (div)  {'+
    'if  ((scrLeft+scrW)>='+divW+') {scrLeft=0;  xSpeed=0;}'+
    'if ((scrTop+scrH)>='+divH+') {scrTop=0;  ySpeed=0;}'+
   '}'+
   'scrollBy(xSpeed,ySpeed);'+
  '}';
timer = setInterval(asCmd,  50);
}}

and I added
 this.asCmd = '';
 this.autoScroll  = ilsAutoScroll;
to the InlineScrollbox function. (Defining the interval sctring as a separate variable isn't really necessary: i just did that to keep my brain straight.)

This works fine, though there's no pause on wrapping -- not a problem, from my point of view. You mentioned that you might add autoscrolling capabilities one day; you're free to use this, if you want.

I'm off to work on the mouseovers, now.

-garison

2) Angus Turnbull Group: Guests
IP: 210.54.--.--
Thanks for the code :). It does look largely like the setScroll() function, especially with the interval, so I think perhaps a quicker way of implementing it would be to just implement a "no bounds checking" setting that the existing scrolling function would use to set the scroll position to 0 instead of nearly-all-the-way-across when you reach the edge?

Anyway, I'll have a think about it...

Cheers - Angus.

3) Garison Piatt Group: Guests
IP: 24.25.--.--
So how do you do "no bounds checking"?

I worked further on the news-type scroller, tryign to add mouseovers. (Took me a while to get to it, though.) This is what I came up with:

I changed ilsAutoScroll, thus:
 timer = setInterval(
  'with  ('+myName+') {'+
    'if (!pause)  {'+
    'xSpeed='+xDiff+';'+
    'ySpeed='+yDiff+';'+
    'if   (div) {'+
     'if ((scrLeft+scrW)>='+divW+')  {scrLeft=0; xSpeed=0;}'+
     'if ((scrTop+scrH)>='+divH+') {scrTop=0;  ySpeed=0;}'+
    '}'+
    'scrollBy(xSpeed,ySpeed);'+
   '}'+
'}',
  50);
 Note  the addition of "if (!pause)". Needless  to say, I added
  this.pause=false;
to  InlineScrollbox().

Finally, I added
   '  onmouseover="'+myName+'.pause=true;" onmouseout="'+myName+'.pause=false;"
to the document.write in ilsStartPage(), and hard-coded the same in the IFRAMEs (NS4 is such a PITA).

It works pretty well, on IE6, NS7, and NS4. It ws actually pretty easy to figure out; I'm posting it here in case someone wants to borrow my brain, the same was I borrowed yours. :)


-garison

Post a Reply:

You are not logged in, and will be posting anonymously as a guest. If you want to post using an account, please login at the top of this page.