javascript - How to make this slider control to work in both directions? -


I am trying to create a range slider but it is only working in one direction (right) and the original Dragging from the container (#volume). How can I fix this?

I've attached a demo bedlake link.

Markup

  & lt; Div id = "volume" & gt; & Lt; Div class = "progress" & gt; & Lt; Div class = "volume slider" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

css

  # volume {width: 300px; Background: #ddd; Cursor: indicator; }. Progress {height: 10px; Background: # 999; Status: Relative; Width: 0; }. Volumeslider {background: # 808080; Status: Completed; Width: 20px; Height: 20px; Range radius: 15px; Correct: -10 pixels; Top: -5px; Bind ('mousedown', function (e) {$ ('.Volumeslider')}  

JS

  $ ('.bind (' mausomov ' , Function (e) {$ ('progress') width (E. PageX - $ ('progress') offset (). Left + 'px'); $ (this) .css ('left', e.pageX - ($ (this) .width () / 2));}) $ ('.Volumeslider') .bind ('mouseup', function () {$ ('.Volumeslider'). Unbind ('mausomov'); }};});  

JS Friedal:

here How to make an example is that it always works everywhere and if you leave the element, then it will be dragged forever.

This includes checking the boundary and ensuring that the body is quite large, so prevents it from dragging anywhere on the page.

  var Turn on drag = null; function () {console.log ('started to draw', this); var $ this = $ (this); drag = $ this; $ (Document.body) .bind ('mouseup' , StopDrag); $ (Document.body) .bind ('mausomov', drag);} function stopdrop () {console.log ('dragging stopped', [0] dragging); $ (Document.body). Unbreakable ('mouseup', stopdrip); $ (Document.body). Unbreaked ('mausaffe', drag); Dragging = null; } Function drag (e) {var slider = dragging; Var progress = slider. (); Var Container = progress.parent (); Var maxOffset = container.width (); Progress. Vithth (Math. (E. PageX - Progress. Offset). Left, Max Offset) + 'PX'); } $ ('. Vol.moulder'). Tie ('Masudown', start drag);  

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -