html - jquery slider problem -



html - jquery slider problem -

i have slider scrolls on drag using jquery ui handle seems drag far off end of slide bar can anyoune see why might be?

html

<div id="content"> <div id="slidercontent"> <div class="viewer"> <div class="content-conveyor ui-helper-clearfix"> <div class="item"> <img src="images/slide_image_one.png"/> </div> <div class="item"> <img src="images/slide_image_one.png"/> </div> <div class="item"> <img src="images/slide_image_one.png"/> </div> <div class="item"> <img src="images/slide_image_one.png"/> </div> <div class="item"> <img src="images/slide_image_one.png"/> </div> </div> </div> <div id="slider"></div> </div> </div>

css /* sliding banner element */

#slidercontent { width:900px; padding:0 0 0 0;} .viewer { width:900px; height:299px; padding:0px; overflow:hidden; position:relative;} .content-conveyor { width:900px; height:299px; position:relative; } .item { width:450px; height: 299px; float:left;} #slider { margin: 10px 0 0 0; } .ui-slider-horizontal { height: 4px; background: url(../images/slider_bg.png;); border: none; width: 900px; float: left; } .ui-slider .ui-slider-handle { cursor: default; height: 15px; position: absolute; width: 25px; z-index: 2; background: url('../images/slider_handle.png') no-repeat; border: none; }

javascript

<script type="text/javascript"> $(function() { //vars var conveyor = $(".content-conveyor", $("#slidercontent")), item = $(".item", $("#slidercontent")); //set length of conveyor conveyor.css("width", item.length * parseint(item.css("width"))); //config var slideropts = { max: (item.length * parseint(item.css("width"))) - parseint($(".viewer", $("#slidercontent")).css("width")), slide: function(e, ui) { conveyor.css("left", "-" + ui.value + "px"); } }; //create slider $("#slider").slider(slideropts); }); </script>

the slider position based on left position of helper. need have wrapper around positioning, , pull helper margin of half it's width.

see next jsfiddle solution using code.

http://jsfiddle.net/bprw2/1/

or http://jqueryui.com/demos/slider/#side-scroll , open source more extensive example.

hope helps

jquery html css

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -