ember-masonry-grid icon indicating copy to clipboard operation
ember-masonry-grid copied to clipboard

infinite scrolling

Open pedropaf opened this issue 9 years ago • 6 comments

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

pedropaf avatar May 07 '15 22:05 pedropaf

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.

gmurphey avatar May 24 '15 15:05 gmurphey

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

thanks again :smile:

xypaul avatar Aug 10 '15 14:08 xypaul

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

t4t5 avatar Aug 13 '15 11:08 t4t5

+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 avatar Aug 27 '15 22:08 dzbo

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);
      }
    });
  })

dzbo avatar Aug 28 '15 11:08 dzbo

@dzbo nice one that looks almost too easy

xypaul avatar Aug 29 '15 00:08 xypaul