<!doctype html><htmllang="en"><head><title>jQuery UI Slider - Slider scrollbar</title><linktype="text/css"href="../../themes/base/ui.all.css"rel="stylesheet"/><scripttype="text/javascript"src="../../jquery-1.3.1.js"></script><scripttype="text/javascript"src="../../ui/ui.core.js"></script><scripttype="text/javascript"src="../../ui/ui.slider.js"></script><linktype="text/css"href="../demos.css"rel="stylesheet"/><styletype="text/css">#demo-frame>div.demo{padding:10px!important;}.scroll-pane{overflow:auto;}.scroll-content{width:2440px;}.scroll-content-item{width:100px;height:75px;float:left;margin:10px;font-size:3em;padding-top:25px;text-align:center;}.scroll-bar-wrap{clear:left;padding:04px02px;margin:0-1px-1px-1px;}.scroll-bar-wrap.ui-slider{background:none;border:0;height:2em;margin:0auto;}.scroll-bar-wrap.ui-handle-helper-parent{position:relative;width:100%;height:100%;margin:0auto;}.scroll-bar-wrap.ui-slider-handle{top:.2em;height:1.5em;}.scroll-bar-wrap.ui-slider-handle.ui-icon{margin:-8pxauto0;position:relative;top:50%;}</style><scripttype="text/javascript">$(function(){//scrollpane partsvarscrollPane=$('.scroll-pane');varscrollContent=$('.scroll-content');//build slidervarscrollbar=$(".scroll-bar").slider({slide:function(e,ui){if(scrollContent.width()>scrollPane.width()){scrollContent.css('margin-left',Math.round(ui.value/100*(scrollPane.width()-scrollContent.width()))+'px');}else{scrollContent.css('margin-left',0);}}});//append icon to handlevarhandleHelper=scrollbar.find('.ui-slider-handle').mousedown(function(){scrollbar.width(handleHelper.width());}).mouseup(function(){scrollbar.width('100%');}).append('<span class="ui-icon ui-icon-grip-dotted-vertical"/>').wrap('<div class="ui-handle-helper-parent" /></div>').parent();//change overflow to hidden now that slider handles the scrollingscrollPane.css('overflow','hidden');//size scrollbar and handle proportionally to scroll distancefunctionsizeScrollbar(){varremainder=scrollContent.width()-scrollPane.width();varproportion=remainder/scrollContent.width();varhandleSize=scrollPane.width()-(proportion*scrollPane.width());scrollbar.find('.ui-slider-handle').css({width:handleSize,'margin-left':-handleSize/2});handleHelper.width('').width(scrollbar.width()-handleSize);}//reset slider value based on scroll content positionfunctionresetValue(){varremainder=scrollPane.width()-scrollContent.width();varleftVal=parseInt(scrollContent.css('margin-left'));varpercentage=Math.round(leftVal/remainder*100);scrollbar.slider("value",percentage);}//if the slider is 100% and window gets larger, reveal contentfunctionreflowContent(){varshowing=scrollContent.width()+parseInt(scrollContent.css('margin-left'));vargap=scrollPane.width()-showing;if(gap>0){scrollContent.css('margin-left',parseInt(scrollContent.css('margin-left'))+gap);}}//change handle position on window resize$(window).resize(function(){resetValue();sizeScrollbar();reflowContent();});//init scrollbar sizesetTimeout(sizeScrollbar,10);//safari wants a timeout});</script></head><body><divclass="demo"><divclass="scroll-pane ui-widget ui-widget-header ui-corner-all ui-helper-clearfix"><divclass="scroll-content"class="ui-helper-clearfix"><divclass="scroll-content-item ui-widget-header">1</div><divclass="scroll-content-item ui-widget-header">2</div><divclass="scroll-content-item ui-widget-header">3</div><divclass="scroll-content-item ui-widget-header">4</div><divclass="scroll-content-item ui-widget-header">5</div><divclass="scroll-content-item ui-widget-header">6</div><divclass="scroll-content-item ui-widget-header">7</div><divclass="scroll-content-item ui-widget-header">8</div><divclass="scroll-content-item ui-widget-header">9</div><divclass="scroll-content-item ui-widget-header">10</div><divclass="scroll-content-item ui-widget-header">11</div><divclass="scroll-content-item ui-widget-header">12</div><divclass="scroll-content-item ui-widget-header">13</div><divclass="scroll-content-item ui-widget-header">14</div><divclass="scroll-content-item ui-widget-header">15</div><divclass="scroll-content-item ui-widget-header">16</div><divclass="scroll-content-item ui-widget-header">17</div><divclass="scroll-content-item ui-widget-header">18</div><divclass="scroll-content-item ui-widget-header">19</div><divclass="scroll-content-item ui-widget-header">20</div></div><divclass="scroll-bar-wrap ui-widget-content ui-corner-bottom"><divclass="scroll-bar"></div></div></div></div><!-- End demo --><divclass="demo-description"><p>Use a slider to manipulate the positioning of content on the page. In this case, it acts as a scrollbar with the potential to capture values if needed.</p></div><!-- End demo-description --></body></html>