简体   繁体   中英

jQuery slimScroll scroll bar with fixed height

I am using the rochal's jQuery plugin slimScroll to display a customized scrollbar. Is there a way to make the height of the scrollbar fixed, not autogenerated? I think that the wheelStep value must be generated, but don't know what to change. So, question is how to make a fixed size scroll bar.

Also I could use another plugin if this is imposible.

It is posible! To achieve this do the following:

After:

// sets border radius of the rail
railBorderRadius : '7px'

Add comma after '7px' and:

// Use a fixed height for the scroll bar
useFixedHeight : true,

// the fixed height of the scroll bar
fixedHeight : 50

Replace:

barHeight = Math.max((me.outerHeight() / me[0].scrollHeight) * me.outerHeight(), minBarHeight);

With:

if( o.useFixedHeight )
    barHeight = o.fixedHeight;
else
    barHeight = Math.max((me.outerHeight() / me[0].scrollHeight) * me.outerHeight(), minBarHeight);

i have try with a simple trick..

first add a class to scroll bar, by default it is 'slimScrollBar'

barClass : 'slimScrollBar_new'

<script>
    $('#scroll-content').slimScroll({
        size : '3px',
        alwaysVisible: true,
        barClass : 'slimScrollBar_new'
    });
</script>

<style>
  .slimScrollBar_new{
      height: 100px !important;
   }
</style>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM