Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinitialising causes extra growth issues when the target element has padding. #51

Closed
DragonDTG opened this issue Feb 19, 2011 · 3 comments

Comments

@DragonDTG
Copy link

When reinitialising the scroll pane, you perform a statement to see if the containing space has changed with this line:

hasContainingSpaceChanged = elem.innerWidth() + originalPaddingTotalWidth != paneWidth || elem.outerHeight() != paneHeight;

However, during initialization, the element's padding has been consumed into the element's innerWidth, moved to the jspPane, and the element's padding is set to 0. Therefore, I believe this line and the subsequent line should be changed to (With the assumption that no other external forces re-added the padding back into the element):

hasContainingSpaceChanged = elem.innerWidth() != paneWidth || elem.outerHeight() != paneHeight;

if (hasContainingSpaceChanged) {
    // paneWidth = elem.innerWidth() + originalPaddingTotalWidth;
    // Change to
    paneWidth = elem.innerWidth();
    paneHeight = elem.innerHeight();
    container.css({
        width: paneWidth + 'px',
        height: paneHeight + 'px'
    });
}

On the note of padding consumption, when destroying the scroll pane, we should re-add the padding back in and re-size the original element as well as removing the 'jsp' from the data. Therefore I propose adding these line to the destroy method.

elem.css('padding', originalPadding);
elem.width(paneWidth - originalPaddingTotalWidth);
elem.data('jsp', null);

I was creating a ui combobox that uses your scrollbar instead of the native one. However when the results returned something that didn't need scrolling, I would just destroy the scrollbar if there was one. The padding is used to allow the browser
to render a border radius-correctly.

BTW, this is a wonder plugin, thanks!!!

@willsteinmetz
Copy link

I was having the same problem and applied the fix to the code above. The fix seems to be working with both of the jScrollPanes that are on the page.

@willsteinmetz
Copy link

After some more testing, this problem curiously only seems to happen when there are multiple jScrollPanes on a page (at least for me.) I'm using version 2.0 beta 11.

Another possible cause (other than multiple instances) could be that the div boxes having jScrollPanes added to them are positioned absolutely. I've seen JavaScript act funky in that case in some browsers where it can't figure out what to do with sizing something or moving it.

@illuusio
Copy link
Collaborator

If this is still issue please write note and i'll reopen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants