set the focus on the scroller when button is clicked

Posted by liz on Stack Overflow See other posts from Stack Overflow or by liz
Published on 2010-05-25T22:33:26Z Indexed on 2010/05/25 22:41 UTC
Read the original article Hit count: 336

Filed under:
|

hi i have a script

<script type="text/javascript">
window.addEvent('domready', function(){ 
      var totIncrement      = 0;
      var increment         = 560;
      var maxRightIncrement = increment*(-6);
      var fx = new Fx.Style('slider-list', 'margin-left', {
                duration: 1000,
                transition: Fx.Transitions.Back.easeInOut,
                wait: true
       });

       //-------------------------------------
      // EVENTS for the button "previous"
      $('previous').addEvents({ 
          'click' : function(event){ 
          if(totIncrement<0){
                    totIncrement = totIncrement+increment;
                    fx.stop()
                    fx.start(totIncrement);
                }
            }                 
      }); 

       //-------------------------------------
      // EVENTS for the button "next"
      $('next').addEvents({ 
          'click' : function(event){ 
             if(totIncrement>maxRightIncrement){
                 totIncrement = totIncrement-increment;
                fx.stop()
                fx.start(totIncrement);
            }
          }               
      })


});
    </script>

in mootools v1.1

it makes a scroller function at the bottom of my html page. but when i click the next button the page's focus moves to the top of the page. how do i keep it on the scroller?

this is the html fragment:

<h3>Our Pastas</h3>

<div id="slider-buttons">
<a href="#" id="previous">Previous</a> | <a href="#" id="next">Next</a&gt;
</div>

<div id="slider-stage">
<ul id="slider-list">

<li class="list_item">

<div id="thumbnail"><a href="xxx/product-catalog/pasta/long-pasta-in-brown-bags/bucatini"><img src="xxx/images/stories/products/_thumb1/bucatini.gif"></a></div><h4><a href="xxx/product-catalog/pasta/long-pasta-in-brown-bags/bucatini">Rustichella d'Abruzzo Bucatini</a></h4>
</li>


<li class="list_item">
<div id="thumbnail"><a href="xxx/product-catalog/pasta/pasta-in-trays/calamarata"><img src="xxx/images/stories/products/_thumb1/calamarata.jpg"></a></div><h4><a href="xxx/product-catalog/pasta/pasta-in-trays/calamarata">Rustichella d'Abruzzo Calamarata</a></h4>
</li>


<li class="list_item">
<div id="thumbnail"><a href="xxx/product-catalog/pasta/pasta-in-trays/cannolicchi"><img src="xxx/images/stories/products/_thumb1/cannolicchi.jpg"></a></div><h4><a href="xxx/product-catalog/pasta/pasta-in-trays/cannolicchi">Rustichella d'Abruzzo Cannolicchi</a></h4>
</li>


</ul></div>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about mootools