Re: How to disable Horizontal Scrollbar?

160 views
Skip to first unread message

Giordano Pellegri

unread,
Dec 6, 2014, 10:04:38 AM12/6/14
to jscro...@googlegroups.com

Hi Pratik,

I've discovered Jsp just yesterday and I've your some requirement, to disable the horizontal scrollbar.
I have a solution (not full tested but it's working), you need to edit the file jquery.jscrollpane.js and add the following changes

  • in function JScrollPane(elem, s) after the variables declaration add these
    var canScrollH = (elem.css("overflow-x") == "hidden") ? false : true;
    var canScrollV = (elem.css("overflow-y") == "hidden") ? false : true;

  • in function initialise(s) change these declarations
    isScrollableV = canScrollV && (percentInViewV > 1);
    isScrollableH = canScrollH && (percentInViewH > 1);

  • always in function initialise(s) change this assignment
    pane.css({
    top: 0,
    left: 0,
    width: container.width() - originalPaddingTotalWidth
    });

    with this

    if (!canScrollH) {
       var ScrollHSize = (contentWidth > container.width()) ? (contentWidth - container.width()) : 0;
       pane.css({
       top: 0,
       left: 0,
       width: container.width() - originalPaddingTotalWidth - ScrollHSize
       });
    }
    else {
       pane.css({
       top: 0,
       left: 0,
       width: container.width() - originalPaddingTotalWidth
       });
    }

Now you can use the css style to disable the scrollbars, to disable the horizontal scrollbar you can add the style overflow-x:hidden; to the control to which you applied the .jScrollPane() plugin.

With or without this change if you find a wrong horizontal dimension of your control content with the vertical scrollbar width you can try to change in function resizeScrollbars() this assignment

if (isScrollableH) {
pane.width((container.outerWidth() - originalPaddingTotalWidth) + 'px');

with this

if (isScrollableH) {
scrollbarWidth = settings.verticalGutter + ((verticalTrack !== undefined) ? verticalTrack.outerWidth() : 0);
pane.width((container.outerWidth() - scrollbarWidth - originalPaddingTotalWidth) + 'px');


enjoy
regards,
Giordano Pellegri


On Tuesday, November 20, 2012 10:06:24 AM UTC+1, Pratik Shah wrote:
Hi,

As per my requirement i don't want horizontal scrollbar completely. Is there any way to disable the horizontal scroll?

Apart from this, is there any way to always show vertical scroll whether the content is scrollable or not?

Please help.

Regards,
Pratik Shah
 
Reply all
Reply to author
Forward
0 new messages