mharris717 / ember-cli-pagination

Pagination Addon for Ember CLI
MIT License
272 stars 116 forks source link

Scroll to top on page query #167

Open stevetyler opened 8 years ago

stevetyler commented 8 years ago

Similar to Google, I'd like to scroll to top when going to a new page. I could use an observer but would rather the addon did this? Many thanks

mr339 commented 7 years ago

Have you found the solution @stevetyler ?

brunoocasali commented 5 years ago

@stevetyler and @mr339 I'm using in combination with ember-router-scroll addon.

I've refactored to use ember-concurrency too, so to get it working I've just set to "remember" my screen location, and then release it.

  pageClicked: task(function * (number) {
    this.scroll && this.set('scroll.preserveScrollPosition', true);

    yield timeout(1000);

    this.set('currentPage', number);

    this.scroll && this.set('scroll.preserveScrollPosition', false);
  }),

But, sometimes it does not work because I don't know when to "release" it, so to get it working i've just set a timeout with 1000ms.

But I've open an issue: https://github.com/mharris717/ember-cli-pagination/issues/273 about how to get right time to release the screen locker.