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

Scrolling wrong in page changes #2 #506

Closed
dangreen opened this issue May 13, 2015 · 2 comments
Closed

Scrolling wrong in page changes #2 #506

dangreen opened this issue May 13, 2015 · 2 comments

Comments

@dangreen
Copy link

This issue is still relevant.

@aliksend
Copy link

Please, try to use my pull request to racer. It is working for me for reactive pagination, wanna to know your feelings

My paginator component:

class CardsList_Paginator
    create: (model) ->      
        model.start 'pages', model.scope('_page.cards_count'), model.scope('_session.cards_in_page'), (cards_count, cards_in_page) -> 
            last = Math.ceil cards_count / cards_in_page
            last = 1 if last == 0
            [0..last - 1]
    previousPage: (ev) ->
        page = app.model.get '_session.page_index'
        page -= 1
        page = 0 if page < 0
        @gotoPage ev, page
    nextPage: (ev) ->
        page = app.model.get '_session.page_index'
        page = 1 unless page
        page += 1
        last = @model.get 'pages'
        last = last[last.length - 1]
        page = last if page > last
        @gotoPage ev, page
    gotoPage: (ev, page) ->
        app.model.set '_session.page_index', page
        body = $ "html, body"
        body.animate { scrollTop:0 }, '500', 'swing'
        do ev.preventDefault

and view (bootstrap 3)

paginator:
    ul.pagination(class='{{if !pages || pages.length == 1}}hidden{{/}}')
        li
            a(href="#" aria-label="Previous" on-click='previousPage($event)')
                span(aria-hidden="true") &laquo;
        each pages as #page
            li 
                a(href="#" on-click='gotoPage($event, #page)') {{#page + 1}}
        li
            a(href="#" aria-label="Next" on-click='nextPage($event)')
                span(aria-hidden="true") &raquo;

May be it is not a best solution, but it is working. Want to know your opinion

@craigbeck
Copy link
Contributor

Thanks for your contributing your issue.

We have recently been actively updating the Derby and Racer packages, and both repos are now in Typescript and published with types on npm. As we have quite a few old issues open we have made the decision to close out of date issues.

If this issue still matters to you we encourage reproducing against the current versions of the repo and opening a new issue.

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