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

Can we load it in reverse? #132

Closed
v3ss0n opened this issue Jan 29, 2016 · 8 comments
Closed

Can we load it in reverse? #132

v3ss0n opened this issue Jan 29, 2016 · 8 comments

Comments

@v3ss0n
Copy link

v3ss0n commented Jan 29, 2016

For chat rooms , we need to load data in reverse order , is there feature for it?

@hhff
Copy link
Collaborator

hhff commented Jan 29, 2016

yessir

afterInfinityModel(newObjects) {
  return newObjects.reverse()
}

@hhff
Copy link
Collaborator

hhff commented Jan 29, 2016

but this is better done on the server of course

@v3ss0n
Copy link
Author

v3ss0n commented Jan 30, 2016

Yes it will be on server
But the display order is reversed. latest first and scroll up to load more
Thanks gonna test it out
On Jan 29, 2016 9:55 PM, "Hugh Francis" [email protected] wrote:

but this is better done on the server of course


Reply to this email directly or view it on GitHub
#132 (comment)
.

@hhff hhff closed this as completed Mar 11, 2016
@williamweckl
Copy link

@v3ss0n did you do that? How can I configure Infinity to scroll up instead down?

@williamweckl
Copy link

I'm trying to make infinity model unshift new objects instead push, is that possible?

@williamweckl
Copy link

williamweckl commented Sep 20, 2016

update: to do the unshift I did:

InfinityRoute.reopen({
  _doUpdate(newObjects) {
    let infinityModel = this._infinityModel();
    return infinityModel.unshiftObjects(newObjects.get('content'));
  }
});

But I did not figured out how to invert the scroll event to UP instead DOWN yet.

@davidgoli
Copy link
Collaborator

@williamweckl the "trigger" for loading more is in the infinity-loader component, and is implemented like so:

  _bottomOfScrollableOffset() {
    return this.get('_scrollable').height() + this.get("_scrollable").scrollTop();
  },

  _triggerOffset() {
    return this._selfOffset() - this.get('triggerOffset');
  },

  _shouldLoadMore() {
    if (this.get('developmentMode') || this.isDestroying || this.isDestroyed) {
      return false;
    }

    return this._bottomOfScrollableOffset() > this._triggerOffset();
  },

If you want to trigger load in a direction that's not down, you'd have to reimplement this code (especially _bottomOfScrollableOffset and _shouldLoadMore). You might try subclassing infinity-loader, or reimplementing with your own component. Better yet, a pull request to indicate direction either in an attribute or as a different component would be helpful...

@williamweckl
Copy link

Opened :)
#182

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

4 participants