Recently done a tax on the function, it is worth saying that the slider implementation of this page. We all know that most of the real programmers are not familiar with the page and art.
I am also, but I prefer to do their own work to achieve. Don't say much nonsense. Image above:
Implementation results:
part of the JS code:
Copy Code code as follows:
Window.onload = function ()
{
var Owin = document.getElementById ("Win");
var bdrag = false;
var disx = Disy = 0;
Owin.onmousedown = function (event)
{
var event = Event | | window.event;
Bdrag = true;
DISX = Event.clientx-owin.offsetleft;
This.setcapture && this.setcapture ();
return False
};
Owin.onmousemove = function (event)
{
if (!bdrag) return;
var event = Event | | window.event;
var IL = Event.clientx-disx;
var MaxL = 480;
Il = il < 0? 0:il;
Il = il > maxL? Maxl:il;
OWin.style.marginTop = OWin.style.marginLeft = 0;
OWin.style.left = IL + "px"; The slider's position from the left
document.getElementById ("Hkline"). Style.width = IL; The width of the green entry on the left side of the slider
return False
};
Document.onmouseup = Window.onblur = Owin.onlosecapture = function ()
{
Bdrag = false;
Owin.releasecapture && owin.releasecapture ();
};
};
Description:
1, the main use of onmousedown and onmousemove recorded after the drag position. And then through the DOM operation to change the corresponding component rendering
Note:
Because the company network is not very ideal. When you get home, you upload all the source code.