Mouse Control scroll bar

Source: Internet
Author: User

<div id= ' out ' style= ' Width:500px;height:500px;overflow:auto ' >          <div id= ' inside ' style= ' width:1000px; Height:1000px;background-color:gray;overflow:auto ' >          </div>      

  

var outdiv = document.getElementById (' out ');          Outdiv.onwheel = function (event) {              //disables the event default behavior (here the mouse wheel behavior is not associated to the "screen scroll bar moves up or down" behavior)              Event.preventdefault ();              Set the move step of the screen scroll bar when the mouse wheel scrolls              var step =;              if (Event.deltay < 0) {                  //scroll up the mouse wheel, the screen scroll bar moves left                  this.scrollleft-= step;              } else {                  //Scroll down the mouse wheel, the screen scroll bar moves right                  This.scrollleft + = step;              }          }        /**            //If you want to manually set the position of the scroll bar in the y-axis direction, you can set the scrolltop directly, for example:            outdiv.scrolltop = x;            If you want to manually set the position of the scroll bar in the x, Y axis direction you can use the function scrollTo, for example set the x-axis scrolling 100,y axis scroll:            outdiv.scrollto (100,400);        **/

  

Mouse Control scroll bar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.