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

Scroll bar is not included in grid mode item position calculation. #241

Closed
2 of 8 tasks
bwh-rl opened this issue May 9, 2016 · 2 comments
Closed
2 of 8 tasks

Scroll bar is not included in grid mode item position calculation. #241

bwh-rl opened this issue May 9, 2016 · 2 comments
Labels

Comments

@bwh-rl
Copy link
Contributor

bwh-rl commented May 9, 2016

Description

Scroll bar is not included in grid mode item position calculation.

Expected outcome

e.g. Viewport width is 520px, scrollbar takes 20px, and one item 250px, i expect that 2 items are in one row and the viewport is exactly filled.

Actual outcome

The positions are calculated like there is no scrollbar, leading to an 10px margin on the left side and an horizontal scrollbar.

Live Demo

https://jsbin.com/hokulijenu/5/edit?html,output
Seems like inline dom-module does not work in jsbin.

Steps to reproduce

<dom-module id="grid-test">
    <template>
        <iron-list items="[[ items ]]" grid class="fit">
            <template>
                <div style="width: 250px; height: 250px; padding: 24px; border: 1px solid grey;">[[ item ]]</div>
            </template>
        </iron-list>
    </template>
</dom-module>

<script>
    Polymer({
        is: "grid-test",
        ready: function() {
            this.items = [
                '1','2','3','4','5','6','7','8','9','0',
                '1','2','3','4','5','6','7','8','9','0',
                '1','2','3','4','5','6','7','8','9','0',
                '1','2','3','4','5','6','7','8','9','0',
                '1','2','3','4','5','6','7','8','9','0',
                '1','2','3','4','5','6','7','8','9','0',
                '1','2','3','4','5','6','7','8','9','0',
                '1','2','3','4','5','6','7','8','9','0',
                '1','2','3','4','5','6','7','8','9','0'
            ];
        }
    });
</script>

Browsers Affected

Thus scrollbars are taking no room on mobiles and on safari these are not affected.
I have not tested this on any microsoft browser.
Probably it does not occur on Chrome or FF on OS X.

  • Chrome
  • Firefox
  • Safari 9
  • Safari 8
  • Safari 7
  • Edge
  • IE 11
  • IE 10
@blasten
Copy link
Contributor

blasten commented May 19, 2016

Thanks for the report. I was aware of this issue, but it's time to fix it :) Ref: PolymerElements/iron-scroll-target-behavior#17

@blasten blasten added the bug label May 19, 2016
@bwh-rl
Copy link
Contributor Author

bwh-rl commented May 20, 2016

Thanks for the feedback, but PolymerElements/iron-scroll-target-behavior#17 would not 100% solve this. As i wrote in the PR, in the docs about the --iron-list-items-container mixin, there is an example with an margin, but this margin would also have no affect to the item position calculation. Since the elements are placed inside the #items, the position calculations should be based on #items, not on the scrollTarget.

blasten pushed a commit that referenced this issue Jun 14, 2016
* Change the _viewportWidth from the scrollTarget width to the items container width.

In the doc there is an demo of giving an margin to the items container via the --iron-list-items-container mixin. But if the viewport is measured from the scrollTarget, the _itemsPerRow calculation and the rowOffset calculation don't include the margin. Same goes for the width of an Scrollbar.

* Changed method to measure item width...

...  from offsetWidth to getBoundingClientRect().width to get exact value instead of an integer.
@blasten blasten closed this as completed Jun 14, 2016
Doncaster pushed a commit to Doncaster/iron-list that referenced this issue Aug 12, 2016
* Change the _viewportWidth from the scrollTarget width to the items container width.

In the doc there is an demo of giving an margin to the items container via the --iron-list-items-container mixin. But if the viewport is measured from the scrollTarget, the _itemsPerRow calculation and the rowOffset calculation don't include the margin. Same goes for the width of an Scrollbar.

* Changed method to measure item width...

...  from offsetWidth to getBoundingClientRect().width to get exact value instead of an integer.
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