www.webdeveloper.com
Results 1 to 1 of 1

Thread: auto scroll on mousemove?

Threaded View

  1. #1
    Join Date
    Oct 2011
    Location
    Hamilton, Ontario
    Posts
    74

    auto scroll on mousemove?

    trying to get this to auto scroll when the mouse moves past a certain point.. the #mousepos element constantly updating mouse position works fine but I can't get the scroll to work.. what am I missing? is there a parameter for 'scrollright()' that i am missing

    here's my code:
    Code:
                $(document).ready(function(){
                    $('#prev').mousemove(function (e){
                        var x = e.pageX - this.offsetLeft;
                        var y = e.pageY - this.offsetTop;
                        if (x>=1200){
                            $('#prev').scrollRight();
                        }
                       $('#mousepos').html(x +', '+ y);
                       
                    }); 
                })
    Code:
       <div id='prev'>
          <table>
             <tr>
                <td align='center'><img src='mypics/tmp5pic3.jpg' />TITLE</td>
                <td align='center'><img src='mypics/tmp5pic4.jpg' />TITLE</td>
                <td align='center'><img src='mypics/tmp5pic5.jpg' />TITLE</td>
                <td align='center'><img src='mypics/tmp5pic6.jpg' />TITLE</td>
             </tr>
          </table>
       </div>
    if have also tried replacing the '$('#prev').scrollRight();' with 'var divscroll=setTimeout(scrolldiv(), 50);' and then adding
    function scrolldiv(){
    document.getElementById('prev').scrollBy(20);
    }

    but to no avail
    Last edited by thewebiphyer; 04-17-2013 at 04:32 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles