0 Replies - 703 Views - Last Post: 07 May 2013 - 12:05 PM

#1 thewebiphyer  Icon User is offline

  • New D.I.C Head

Reputation: -8
  • View blog
  • Posts: 5
  • Joined: 07-May 13

problem with auto scroll on mouse position?

Posted 07 May 2013 - 12:05 PM

I am using this code to try and get an html div to scroll when I move the mouse over the far left or far right sides of the div, but it only scrolls when them mouse is moving, not when it is still.. i know this is because of the 'mousemove' method in my script, but when i switch it to, 'mouseenter', it doesn't do anything at all and I know mouseenter isn't constantly checking the mouse position.. i tried using a time as well, but, again the scroll actions only apply when a mousemove is detected.. is there any ways to make it so that it scrolls when my mouse is just sitting still over the specified pixel area? I'm not getting any errors either so no issues there
            var num=0; var x, y;
            $(document).ready(function(){
                $(document).mousemove(function(e){
                    $('#p').html(e.pageX +', '+ e.pageY);
                    x = e.pageX;
                    y = e.pageY;
                    if (x>9 && x<50/* && y<209 && y>8*/){
                        $('div').scrollLeft(num);
                        if(num>0){
                            num-=15;
                            document.getElementById('x').innerHTML=num;
                        }
                    }
                    if (x>760 && x<809/* && y<209 && y>8*/){
                        $('div').scrollLeft(num);
                        if(num<944){
                            num+=15;
                            document.getElementById('x').innerHTML=num;
                        }
                    }
                });
            });


    
        <body >
        <div style='height:200px; width:800px; border:1px black solid;' <!--onmouseover='mouse_position(event)'-->
            <h2><nobr>HELLO MY NAME IS [mod edit: named removed] I AM TRYING TO MAKE THIS ANIMATION WORK.
            MAYBE IT WILL WORK WITH SOME CAREFUL RESEARCH.</nobr></h2>
        </div>
        <p id='p'>a</p>
        <p id='x'>a</p>
    </body>


This post has been edited by modi123_1: 07 May 2013 - 12:20 PM
Reason for edit:: removed contact information


Is This A Good Question/Topic? 0
  • +

Page 1 of 1