lokyoung / vuejs-paginate

A Vue.js(v2.x+) component for creating pagination.
MIT License
778 stars 171 forks source link

Page range is being added on both sides of selected page #68

Closed keeganstreet closed 6 years ago

keeganstreet commented 6 years ago

Steps to reproduce:

<paginate :page-count="10" :margin-pages="0" :page-range="5" />

Click Next 10 times to skip through all pages.

Expected result:

The number of displayed page numbers adheres to the page-range configuration value. 5 page numbers should be visible at all times.

Actual result

On page 1, 5 pages are displayed. On page 2, 6 pages are displayed. On page 3, 7 pages are displayed. On page 4, 8 pages are displayed. On page 5, 9 pages are displayed. On page 6, 9 pages are displayed. On page 7, 8 pages are displayed. On page 8, 7 pages are displayed. On page 9, 6 pages are displayed. On page 10, 5 pages are displayed.

before

PR with fix coming shortly.

lokyoung commented 6 years ago

Hi @keeganstreet . Previously i just use the same way as your PR. But i find maybe it will be little confused when the page-range is even number. eg. If the page-range is 5, we can add 2 page items on both side of selected page. But if the page-range is 4. What it should be? I think it may confused the user. I'm open to your suggestion. And I'm very happy to discuss this question with you. Thank you very much.

lokyoung commented 6 years ago

BTW. I have checked your PR. It's very awesome! Example and test cases are both added. I'm really appreciate.

keeganstreet commented 6 years ago

Hey @lokyoung, thanks! Nice work on the component overall!

Maybe we could update the readme to say: It is recommended to use an odd number, so that the same number of pages are displayed before and after the active page.

keeganstreet commented 6 years ago

Hi @lokyoung, as my PR currently stands, if a developer specifies an even number for the page-range parameter, there will be one more page number before the active page than after the current page. I can reverse that if you prefer. I honestly think it would be better to just update the docs to recommend that an odd number is used for this parameter. It looks much nicer when its symmetrical.

lokyoung commented 6 years ago

HI @keeganstreet , I agree with you. I'll merge your PR and update the documentation. Thanks.

lokyoung commented 6 years ago

Hi @keeganstreet . I have updated the documentation and publish this modification in v1.8.0. You can check if it's ok. Anything you feel not appropriate you can just reopen this issue or open another, I'm happy to check the feedback. I must say thank you.

keeganstreet commented 6 years ago

Thanks @lokyoung 👍 Thanks for a good pagination component!