gmurphey / ember-masonry-grid

An ember-cli addon to quickly and easily create grids using Masonry.
MIT License
37 stars 29 forks source link

infinite scrolling #16

Open pedropaf opened 9 years ago

pedropaf commented 9 years ago

do you support infinite scrolling? I have seen that the list of items is observed, but are they added in a nice way or the whole library is reset?

Thanks

gmurphey commented 9 years ago

Currently, the addon destroys the masonry layout and then re-initializes it when items changes. This is partially due to a lackluster API for the jQuery Masonry plugin. I'm working on a new version of the addon that uses the Masonry library rather than the jQuery plugin, so we can hopefully make adding and removing items more performant.

xypaul commented 9 years ago

@gmurphey thanks for the library. it's really awesome. adding infinite scroll would be the icing on the cake!!!

thanks again :smile:

t4t5 commented 9 years ago

:+1: Love this little library. With infinite scrolling, I will have everything I need! :D

dzbo commented 9 years ago

+1 for this.

I'm trying to do infinite scrolling, but once new items are loaded and masonry re-initialize page jump to top.

dzbo commented 9 years ago

Okay, I've figured out that by myself. I've changed items observer so when new items are added it runs masonry appended method and doesn't re-initialize. It works great now.

layoutMasonry: Ember.observer('items.@each', function () {
    imagesLoaded(this.$(), () => {
      if (!this.get('masonryInitialized')) {
        this.$().masonry(this.get('options'));
        this.set('masonryInitialized', true);
      } else {
        var $new = [];
        $new = $(this.get('options.itemSelector')).filter(function() {
          return $(this).css('position') !== 'absolute';
        });
        this.$().masonry('appended', $new);
      }
    });
  })
xypaul commented 9 years ago

@dzbo nice one that looks almost too easy