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

support for scrollbars that are not full client size - proposition #9

Closed
flexphperia opened this issue Jun 22, 2015 · 6 comments
Closed
Labels

Comments

@flexphperia
Copy link

Now plugin does not support scrollbar width/height that is smaller than clientWidth/clientHeight.

Replace _mouseMoveDocumentHandler method with this:

GeminiScrollbar.prototype._mouseMoveDocumentHandler = function(e) {
    if (this._cursorDown === false) {
        return;
    }

    var offset, thumbClickPosition, thumbPositionPercentage; 

    if (this._prevPageY) {
        offset = ((this._scrollbarVerticalElement.getBoundingClientRect().top - e.clientY) * -1);
        thumbClickPosition = (this._thumbVerticalElement.offsetHeight - this._prevPageY);
        thumbPositionPercentage = ((offset - thumbClickPosition) * 100 / this._scrollbarVerticalElement.offsetHeight); //CHANGE

        this._viewElement.scrollTop = (thumbPositionPercentage * this._viewElement.scrollHeight / 100);

        return;
    }

    if (this._prevPageX) {
        offset = ((this._scrollbarHorizontalElement.getBoundingClientRect().left - e.clientX) * -1); 
        thumbClickPosition = (this._thumbHorizontalElement.offsetWidth - this._prevPageX);
        thumbPositionPercentage = ((offset - thumbClickPosition) * 100 / this._scrollbarHorizontalElement.offsetWidth); //CHANGE

        this._viewElement.scrollLeft = (thumbPositionPercentage * this._viewElement.scrollWidth / 100);
    }
};
@flexphperia
Copy link
Author

noeldelgado, can you review this change?
It works fine, but sometimes (on different scroll sizes) thumb do not touch end border of scrollbar when scrolled to end.

EDIT: this happens only on Chrome - possible cause: rounding method of css values

@noeldelgado
Copy link
Owner

You are right, I just tried and I can confirm. This also happens if you put some offsets for the gm-scrollbar -vertical and/or gm-scrollbar -horizonta elements. e.g. top: 20px; bottom: 20px.

I also found that the _clickVerticalTrackHandler and _clickHorizontalTrackHandler methods will need to be fixed as well.

Changing

var thumbPositionPercentage = ((offset - thumbHalf) * 100 / this._viewElement.clientHeight);
// to
var thumbPositionPercentage = ((offset - thumbHalf) * 100 / this._scrollbarVerticalElement.offsetHeight);

and

var thumbPositionPercentage = ((offset - thumbHalf) * 100 / this._viewElement.clientWidth);
// to
var thumbPositionPercentage = ((offset - thumbHalf) * 100 / this._scrollbarHorizontalElement.offsetWidth);

Do you want to do the PR? otherwise I can take it.

thanks!

@flexphperia
Copy link
Author

Thanks. Sorry I dont know what is "PR" so better you do it :)

@noeldelgado
Copy link
Owner

PR = Pull Request

How you ever going into the process of forking and contributing to a project before?

If you want to do it I am more than happy to assist you in any way I can.

If you do not feel like doing it right now, no problem, I just think it could be a good chance in case you haven't done it before :)

@flexphperia
Copy link
Author

Thanks but I'm only commenting and submiting bugs. I'm fine with this for now. I have own something like repository when I collect plugins with changes made by me :)

@noeldelgado
Copy link
Owner

Ok, cool 👍

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

No branches or pull requests

2 participants