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

Native scroll compensation does not work when position != absolute #207

Closed
satazor opened this issue Jan 6, 2014 · 5 comments
Closed

Native scroll compensation does not work when position != absolute #207

satazor opened this issue Jan 6, 2014 · 5 comments
Milestone

Comments

@satazor
Copy link
Contributor

satazor commented Jan 6, 2014

In some cases, I want my .content NOT to be positioned absolutely so that the parent shrinks. For example, imagine a modal dialog with a scroller inside that has a max-height of 500px; if the .content has only 200px, I want the modal to only occupy 200px. I'm positioning .content statically (or relatively) to make it work.

Unfortunately right: -SCROLL_WIDTH does not working on this situation, but margin-right does.

Since I'm inheriting from NanoScroller I've fixed this bug like so:

MyScroll.prototype.reset = function () {
        var position = this.$content.css('position'),
            right;

        NanoScroller.prototype.reset.call(this);

        // Fix bug in nanoscroller because right: -SCROLL_WIDTH does
        // not work when positioning the content relatively
        if (position === 'static' || position === 'relative') {
            right = parseInt(this.$content.css('right'), 10);

            if (right) {
                this.$content.css({
                    right: '',
                    marginRight: right
                });
           }
    }

    return this;
};

I would have made a PR but I don't know coffee script that much.

//cc @kristerkari

@kristerkari
Copy link
Collaborator

Thanks! I'll have to patch this and have a look at the other bugs currently open.

@satazor
Copy link
Contributor Author

satazor commented Jan 7, 2014

Alright, I will remove my fix once done, thanks!

@kristerkari
Copy link
Collaborator

@satazor I pushed your fix now, can you test it out? Thanks a lot.

@satazor
Copy link
Contributor Author

satazor commented Mar 7, 2014

I will be doing it as soon as get back to the project, which will be next week, and report back

@satazor
Copy link
Contributor Author

satazor commented Mar 19, 2014

It's working as expected. I will report back if I see anything wrong. Thanks!

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

2 participants